[R] Ignore escape characters in a string...

Rui Barradas ruipbarradas at sapo.pt
Tue Apr 8 17:35:17 CEST 2014


Hello,

There is support for the clipboard on Windows 7.
Also, note that on Windows your solution leaves a connection open so 
maybe the following is better.

# copy the next line
C:\Program Files\R\R-3.0.3

clipb <- file("clipboard")
winpath <- readLines(clipb)
close(clipb)


And, just to avoid backslashes altogether,

fun <- function(x) gsub("\\\\", "/", x)
fun(winpath)

Hope this helps,

Rui Barradas

Em 08-04-2014 16:17, Barry Rowlingson escreveu:
> On Tue, Apr 8, 2014 at 4:00 PM, Jonathan Greenberg <jgrn at illinois.edu>wrote:
>
>> C:\Program Files\R\R-3.0.3
>
>
> Does R on windows have clipboard support? I can do this on Linux:
>
>   > readLines(file("clipboard"))
> [1] "C:\\Program Files\\R\\R-3.0.3"
>
> - that's from a copy of a path with only single slashes in. But
> help(connections) on my linux system doesn't mention the Windows
> clipboard....
>
> Some ppl on SO have assorted solutions involving Windows scripting tools
> that tweak the clipboard so you can Ctrl-V a modified value:
>
> http://stackoverflow.com/questions/1407238/relief-from-backslash-irritation-in-r-for-windows
>
> Barry
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list