[R] Skipping columns to save memory

Doran, Harold HDoran at air.org
Fri May 30 15:28:56 CEST 2008


Thanks,

read.delim('cleanitem.txt', header = TRUE,  nrows = 10, colClasses =
rep(c("factor", "NULL"), c(1,6)))

Is exactly what I needed. 

> -----Original Message-----
> From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
> Sent: Friday, May 30, 2008 9:25 AM
> To: Doran, Harold
> Cc: R-help at r-project.org
> Subject: Re: [R] Skipping columns to save memory
> 
> On 5/30/2008 8:54 AM, Doran, Harold wrote:
> > I have a very large tab delimited file (~ 1.97 GB) that I 
> need to read 
> > in to R. The data contain 10 columns and there are millions of rows.
> > 
> > I need all rows of the data, but I only need the first 
> column in the 
> > data. I was looking at the ?read.delim and am trying to see 
> if it is 
> > possible to tell this function only to read in the first column and 
> > skip the others.
> > 
> > The help file says the number of columns are determined 
> from the first 
> > 5 rows of the data. So, I think one (very bad) option is to go into 
> > the text file and manually delete columns 2:10 for the 
> first 5 rows only.
> > Then, I think read.delim would think there is only 1 column 
> in the data.
> > 
> > The skip function is of course only for rows AFAIK. 
> > 
> > help.search('skip columns read.delim')
> > 
> > Or  help.search('skip columns') didn't return anything.
> > 
> > Are there arguments in this function I have misunderstood or, are 
> > other functions better for this problem?
> 
> If an entry in colClasses is set to "NULL", then that column 
> is skipped.
> 
> Duncan Murdoch
> 



More information about the R-help mailing list