[R] how do I read only specific columns using read.csv or other read function

Ben Tupper PemaquidRiver at tidewater.net
Wed Jul 2 13:09:53 CEST 2008


On Jul 2, 2008, at 6:53 AM, Philip James Smith wrote:

> Hi R people:
>
> I have huge files with as many as 5000 columns. I'd really like to  
> read only certain columns of those files. I know column names I  
> want to read.
>
> I looked at the documentation of read.csv . Although there is a  
> col.names option, it allows users to specify the names of the  
> columns, rather than to pick the columns of interest.
>
> Any suggestions on how to pick the columns I want to read only,  
> rather than the entire file, would be greatly appreciated.
>

Hello,

I think you want explicitly set the colClasses argument such that the  
columns you *don't* want are set to NULL and all others are set to  
appropriate classes.

Cheers,
Ben






> Phil Smith
> Duluth, GA
>
> ______________________________________________
> 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.

Ben Tupper
PemaquidRiver at tidewater.net

I GoodSearch for Ashwood Waldorf School.

Raise money for your favorite charity or school just by searching the  
Internet with GoodSearch - www.goodsearch.com - powered by Yahoo!



More information about the R-help mailing list