[R] How to read only specified columns from a data file

Luis Ridao luridao at gmail.com
Tue Mar 15 16:52:45 CET 2011


R-help,

I'm trying to read a data file with plenty of columns.
I just need the first 5 but it doe not work by doing something like:

> mycols <- rep(NULL, 430) ; mycols[c(1:4)] <- NA
> read.table(myfile, skip=2, colClasses=mycols)

Any suggestions?

Thanks in advance



More information about the R-help mailing list