Hi,
I have a data file with hundreds of rows, with every first, second, third,
and fourth line representing a set of numbers for row names x, y, fit, and
residuals, respectively. However, any given group of these lines might be
from 10 to 20000 values long.
When I try
fits=read.delim2("test")
Error in read.table(file = file, header = header, sep = sep, quote = quote,
:
more columns than column names
When I try
fits=readLines("test")
it reads the data, but doesn't separate it into
values:> head(fits)
[1] "1\t30049\t30204\tsegment_4\t35\t."
[2]
"bp\t30049\t30065\t30071\t30114\t30119\t30121\t30126\t30130\t30132\t30134\t30137\t30146\t30151\t30165\t30174\t30204\t"
[3] "origScore\t4\t1\t1\t2\t1\t1\t2\t2\t2\t6\t5\t2\t1\t2\t1\t2\t"
[4]
"fit\t2.15669\t2.20976\t2.22514\t2.25842\t2.25336\t2.25082\t2.24318\t2.23576\t2.23161\t2.22718\t2.21999\t2.19465\t2.17818\t2.12334\t2.08169\t1.91129\t"
[5]
"residuals\t1.84331\t-1.20976\t-1.22514\t-0.258424\t-1.25336\t-1.25082\t-0.243182\t-0.235756\t-0.23161\t3.77282\t2.78001\t-0.194654\t-1.17818\t-0.123344\t-1.08169\t0.0887071\t"
Can anyone help me do this?
Thanks,
Sean
--
View this message in context:
http://r.789695.n4.nabble.com/How-do-I-read-multiple-rows-of-different-lengths-tp3015982p3015982.html
Sent from the R help mailing list archive at Nabble.com.
Hi,
I have a data file with hundreds of rows, with every first, second, third,
and fourth line representing a set of numbers for row names x, y, fit, and
residuals, respectively. However, any given group of these lines might be
from 10 to 20000 values long.
When I try
fits=read.delim2("test")
Error in read.table(file = file, header = header, sep = sep, quote = quote,
:
more columns than column names
When I try
fits=readLines("test")
it reads the data, but doesn't separate it into
values:> head(fits)
[1] "1\t30049\t30204\tsegment_4\t35\t."
[2]
"bp\t30049\t30065\t30071\t30114\t30119\t30121\t30126\t30130\t30132\t30134\t30137\t30146\t30151\t30165\t30174\t30204\t"
[3] "origScore\t4\t1\t1\t2\t1\t1\t2\t2\t2\t6\t5\t2\t1\t2\t1\t2\t"
[4]
"fit\t2.15669\t2.20976\t2.22514\t2.25842\t2.25336\t2.25082\t2.24318\t2.23576\t2.23161\t2.22718\t2.21999\t2.19465\t2.17818\t2.12334\t2.08169\t1.91129\t"
[5]
"residuals\t1.84331\t-1.20976\t-1.22514\t-0.258424\t-1.25336\t-1.25082\t-0.243182\t-0.235756\t-0.23161\t3.77282\t2.78001\t-0.194654\t-1.17818\t-0.123344\t-1.08169\t0.0887071\t"
Can anyone help me do this?
Thanks,
Sean
--
View this message in context:
http://r.789695.n4.nabble.com/How-do-I-read-multiple-rows-of-different-lengths-tp3015986p3015986.html
Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2010-Oct-27 19:51 UTC
[R] How do I read multiple rows of different lengths?
On Oct 27, 2010, at 3:27 PM, smcguffee wrote:> > Actually, I take that back, this is only reading in 18 values at the > most in > a list, but some lists should be over 200 values in length... > -- > View this message in context: http://r.789695.n4.nabble.com/How-do-I-read-multiple-rows-of-different-lengths-tp3015986p3016151.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.David Winsemius, MD West Hartford, CT
David Winsemius
2010-Oct-27 19:54 UTC
[R] How do I read multiple rows of different lengths?
On Oct 27, 2010, at 3:27 PM, smcguffee wrote:> > Actually, I take that back, this is only reading in 18 values at the > most in > a list, but some lists should be over 200 values in length...I think the read.table and cousins read in some modest fraction of the data Probably need to either preprocess with readLines if you want an exact match of width or maybe take a guess with ... , colClasses = rep("numeric", 250) to create a sufficiently wide set of columns to hold everything. -- David Winsemius, MD West Hartford, CT