Reading only two out of three columns with read.csv
I have an ascii dataset which consists of three columns, but only the last two are actual data. Now I want to create a dotchart of the data by using
read.csv(file = "result1", sep= " "). R reads all three columns. How do I avoid this?
Actually, the current consensus seems to be that R questions are now welcome in CV. I can't find the discussion right now, but it's somewhere in http://meta.stats.stackexchange.com/.
You can use the
read.csvto select the columns you want. In this case, you can set
c("NULL", NA, NA)
read.csv(file="result1", sep=" ", colClasses=c("NULL", NA, NA))
More generally, you can use colClasses to specify the particular types of columns;
NAmeans to use the default approach which is to try and figure out what the column is automatically. See the help page for
read.csvfor more details.