read.csv() - two out of three columns [duplicate]

2019-04-09 11:27发布

问题:

Possible Duplicate:
Only read limited number of columns in R

I have a ascii-dataset which consists of three columns, but only the last two are actual data. Now I want to dotchart the data by using read.csv(file = "result1", sep= " "). R reads all three columns. How do I avoid this?

回答1:

You can use the colClasses argument to skip columns:

mydata <- read.csv('mydata.csv', colClasses=c('NULL',NA,NA))

or

mydata <- read.csv('mydata.csv', colClasses=c('NULL', 'numeric', 'numeric'))


标签: r read.csv