[R] How do I read multiple rows of different lengths?

smcguffee sean.mcguffee at gmail.com
Wed Oct 27 19:51:41 CEST 2010


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.



More information about the R-help mailing list