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?

-
I'll leave it here, but please ask future basic R questions on StackOverflow. –  mbq Oct 10 '11 at 15:59
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 meta.stats.stackexchange.com. –  Waldir Leoncio Aug 6 at 19:53

You can use the colClasses argument to read.csv to select the columns you want. In this case, you can set colClasses to 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; NA means to use the default approach which is to try and figure out what the column is automatically. See the help page for read.csv for more details.

-
read.csv(file = "result1", sep = " ")[ ,1:2]

read.csv(file = "result1", sep = " ")[ ,c('col1', 'col2')]