[R] skipping columns in read.table; was: (no subject)

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Aug 2 10:42:05 CEST 2013



On 02.08.2013 05:29, Babu Guha wrote:
> I have a comma delimited file with 62 fields of which some are comments.
> There are about 1.5 million records/lines. Sme of the fields which has
> comments and which i do not need have 40 characters. Of the 62 fields, I
> will need at most 12 fields. What's best way to read in the fields I need.
> If I read the entire file at once I will run out of memory. Could anyone
> please suggest some solution?

See ?read.table and its argument colClasses:

read.table(file, colClasses=c("numeric", "NULL", "factor"))

Will read the first column as a numeric one, skip the second column and 
take the thirs one as a factor.

Best,
Uwe Ligges


>
> Thanks,
> Babu.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list