I have a small data from a text file read via readLines
. The file had characters like #
and I think that is the reason read.table was unable to read it. Here is the first five lines dput:
files<-c("\trfinal\t\t", "eq1\t\t\t", "0.ster6\t1.00\t(1.00,1.00)\t.",
"1.ster6\t0.65\t(0.47,0.88)\t0.006", "0.parkinson\t1.00\t(1.00,1.00)\t.",
"1.ster6#0.parkinson\t1.00\t(1.00,1.00)\t.")
\t
means white space between strings. I would like to split this text lines and put them into a 4 column grid (data frame).
I tried strsplit(files, "[\\t]")
but it doesn't really do the trick. Any help ?
You can disable the treatment of #
as the comment.char
in read.table
:
read.table(text=files, sep='\t', comment.char="")
# V1 V2 V3 V4
# 1 rfinal
# 2 eq1
# 3 0.ster6 1.00 (1.00,1.00) .
# 4 1.ster6 0.65 (0.47,0.88) 0.006
# 5 0.parkinson 1.00 (1.00,1.00) .
# 6 1.ster6#0.parkinson 1.00 (1.00,1.00) .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With