问题
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'))
来源:https://stackoverflow.com/questions/7714997/read-csv-two-out-of-three-columns