[R] read.table input array
Balpo
balpo at gmx.net
Fri Jul 16 16:51:59 CEST 2010
Hello to all!
I am new with R and I need your help.
I'm trying to read a file which contests are similar to this:
A B C T Lengths
1 4.0 0.0015258789 18 c(1,2,3)
1 1.0 0.0017166138 24 c(1,1,4)
So all the columns are numeric values, except Lengths, which is supposed to
be an variable length array of integers.
How can I make R read them as arrays of integers? Or otherwise, convert the
character array to an array of integers.
When I read the file, I do it like this
t1 = read.table(file=paste("./borrar.dat",sep=""), header=T,
colClasses=c("numeric", "numeric", "numeric", "numeric", "array"))
But the 5th column is treated as an array of characters, and when trying
to convert it to another class of data, I either
get two strings "c(1,2,3)" and "c(1,1,4)" or using a toRaw converter, I
get the corresponding ASCII ¿? values.
Should the input be modified in order to be able to read it as an array
of integers?
Thank you for your help.
Balpo
More information about the R-help
mailing list