Dear List,
You can read from the OSX clipboard using readLines(pipe("pbpaste"))
However, If you don't have a trailing newline, the last line is silently
skipped. Note readLines(warn=TRUE)'s doesn't produce a waning, thus I think it
doesn't even see the final line.
Simple example:
Select the letters with or without a trailing new line, copy to clipboard, then
A
B
C
D
# without trailing newline
readLines(pipe("pbpaste"))
[1] "A" "B" "C"
# with trailing newline
readLines(pipe("pbpaste"))
[1] "A" "B" "C" "D"
Note that flush()ing the connection does not quite fix the problem
In the more verbose form:
OUT <- pipe("pbpaste")
readLines(OUT)
[1] "A" "B" "C"
isIncomplete(OUT)
[1] TRUE
flush(OUT)
readLines(OUT)
[1] "DA" "B" "C"
The last element gets pre-pended to the first element, so a hack could fix this.
Is this a limitation of pipe, pbpaste, or just a bug?
This is an issue, because i often copy from Excel to 'paste' into R, and a
selection in Excel /never/ adds the trailing new line, even if you select blank
cell(s) below your selection.
cheers,
Mark
-----------------------------------------------------
Mark Cowley, PhD
Pancreatic Cancer Program | Peter Wills Bioinformatics Centre
Garvan Institute of Medical Research, Sydney, Australia
-----------------------------------------------------
[[alternative HTML version deleted]]
_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac