Skip to content

List of lists? Data frames? (Or other data structures?)

2 messages · R A F, Peter Dalgaard

#
Thanks for your comments.  I'm not too familiar with these differences,
but here's a simple experiment.  In a data file with 139,000 rows and
5 columns (double string double double double),
20.67 0.41 21.10 0.00 0.00
6.07 0.01 6.09 0.00 0.00

It seems like scan is much faster -- and as the data file grows,
read.table seems to choke.  (I actually tried this with a data file
with over 2 million rows.)

I'm using a Sun-Sparc, Solaris 2.8 and R 1.5.1.  Sorry I can't be
more specific about the hardware/software configurations, not being
too knowledgeable about this sort of thing.

By the way, it's not possible to create a matrix of mixed types, is
it?  (I don't know how anyway.)

Any ideas as to the speed differences?  Thanks again.
#
"R A F" <raf1729 at hotmail.com> writes:
You're not taking Brian's hint!:
Try this:

cls <- sapply(list(0,"",0,0,0),class)
# older versions may need cls <- c("numeric","character",rep("numeric",3))
aaa <- read.table( "file", colClasses=cls )