Matrix-style indexing works for both columns and rows of data frames. E.g.: > x <- data.frame(a=1:5, b=6:10, d=11:15) > x a b d 1 1 6 11 2 2 7 12 3 3 8 13 4 4 9 14 5 5 10 15 > x[2:4,c(1,3)] a d 2 2 12 3 3 13 4 4 14 >
Time spend reading the help document "An Introduction to R" will probably be well worth it. The relevant sections are "5 Arrays and matrices", and "6.3 Data frames". -- Tony Plate Michael Gormley wrote: > I have created a data frame using the read.table command. I want to be able > to access the rows by the row name, or a vector of row names. I know that you > can access columns by using the data.frame.name$col.name. Is there a way to > access row names in a similar manner? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.