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

你离开我真会死。 提交于 2019-12-06 04:34:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!