Thursday, 15 April 2010

sql - Read in only certain column names from TSV file into R -


I have a large TSV file that I can not read in R due to its size.

I only want to read the header name in the selected column, e.g. "Health".

How can I go about doing this?

See a read.table code colClasses : df & lt; - read.table (header = TRUE, colClasses = c (NA, "NULL", NA), text = 'ABC 1 2 3 4 5 6') DF # AC # 1 1 3 # 2 4 6 < / Pre>

Update:

To select names, first read in the header and then create a vector for the callclass:

  Read the # header header; & Lt; - read.table (header = FALSE, nrow = 1, text = 'ABC 1 2 3 4 5 6') # We want to take the call & lt; - c ('A', 'B') # Create a vector for callclose lecols & lt; - ifelse (t (header) %%, na, 'toll') # selected column df & lt; - read.table (header = TRUE, colClasses = lecoles, text = 'ABC 1 2 3 4 5 6')    

No comments:

Post a Comment