[R] read.table with different row lengths
poliquin at sas.upenn.edu
Wed Dec 10 19:50:50 CET 2008
I need to read in a series of text files with a time series on each
row. The series are of different lengths and I'd like to just use the
first row as the length and have R ignore extra values in rows that go
over this length.
1 0 3 4 5
1 3 5 6 8 7 7
2 1 1 1 4 7 7 7
So the 7s would be ignored and I would have a 5x3 matrix. I tried
creating a series of colClasses with NULLs for the extra values by
using max(count.fields(file)) - min(count.fields(file)) but this
didn't work and would be too time consuming for lots of files.
fill=T doesn't seem to be working either. When I use fill=T I get
extra rows for some reason in the table. R doesn't seem to just be
appending NAs to the end of the short rows.
Any way to accomplish this?
More information about the R-help