reading from clipboard error
Mark Cowley <m.cowley <at> garvan.org.au> writes:
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"
I can replicate this with readLines if I stop the blocking right after the D but not if I take the whole line. I don't get it though with either read.table or scan
readLines(pipe("pbpaste"))
[1] "A" "B" "C"
read.table(pipe("pbpaste"))
V1
1 A
2 B
3 C
4 D
Warning message:
In read.table(pipe("pbpaste")) :
incomplete final line found by readTableHeader on 'pbpaste'
scan(pipe("pbpaste"), what = "character")
Read 4 items [1] "A" "B" "C" "D"
cheers, Mark ----------------------------------------------------- Mark Cowley, PhD Pancreatic Cancer Program | Peter Wills Bioinformatics Centre Garvan Institute of Medical Research, Sydney, Australia -----------------------------------------------------
Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen L?pine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html