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?
It looks like it is documented depending on the blocking
behavior of your connection.
From ?readLines
"If the final line is incomplete (no final EOL marker) the behaviour
depends on whether the connection is blocking or not.
For a non-blocking text-mode connection the incomplete
line is pushed back, silently. For all other connections the
line will be accepted, with a warning.
Whatever mode the connection is opened in, any of LF, CRLF
or CR will be accepted as the EOL marker for a line."
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
-----------------------------------------------------