[Rd] R command line and pipe using in Linux?

Sean O'Riordain seanpor at acm.org
Mon Feb 14 18:51:02 CET 2011

Good afternoon Hang,

This is an example of what I've done with a csv file with a header
which is too big to read into memory.

# this is a file with about 50 columns and 28 million records
ap.fnam <- 'p2_all28m_records.csv'
# lets just explore the columns in Addresspoint...
# by reading in the header and the first row
p1 <- read.csv(ap.fnam, nrows=1)

# now which columns do we actually want?
# ok... in this case we only want the NCAT column...
cols.reqd <- grep('NCAT', names(p1))
# so we create a list containing this/these column(s) as a 'character'
# type and all other columns as 'NULL'...
col.classes <- ifelse(seq(ncol(p1)) %in% cols.reqd, 'character', 'NULL')

# this will likely take a little over a minute!
p9 <- read.csv(ap.fnam, colClasses=col.classes )

Hope this helps

Kind regards,

On 14 February 2011 17:40, Hang PHAN <hangphan at gmail.com> wrote:
> Hi,
> I have a very large data file(GB) from which I only want to extract one
> column to draw histogram. This would be done several times, so I would like
> to ask if there is anyway to plot this using R from the linux command line,
> something look like this
> cut -f1 xxx.txt |RplotHist ....
> Thanks and hope to hear from you.
> Best regards,
> Hang
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list