Skip to content
Prev 179247 / 398506 Next

Way to handle variable length and numbers of columns using read.table(...)

The last line should be as follows (as the previous post missed the
time column).
The regular expression says either start from beginning (^) and look
for a string of digits, [0-9]+, or look for digits [0-9]*, a dot [.] and two
more digits [0-9][0-9].  Each time strapply finds such a match
as.numeric is applied to it.  Thus line of input results in a numeric
vector and then we simplify those vectors by rbind'ing them together.
[,1]   [,2]   [,3]
[1,]    1  22.33  44.55
[2,]    2  66.77  88.99
[3,]    3 222.33 344.55
[4,]    4  66.77  88.99


On Mon, May 4, 2009 at 11:04 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote: