Re: [R] Access Rows in a Data Frame by Row Name

2006-09-13 Thread Anupam Tyagi
I hope this helps. > 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 > # access row with name "a". This does not work. > x$a [1] 1 2 3 4 5 > # access column with name "d" > x$d [1] 11 12 13 14 15 > x$row.names NULL > attributes(x) $names [1]

Re: [R] Access Rows in a Data Frame by Row Name

2006-09-13 Thread Berton Gunter
- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Tony Plate > Sent: Wednesday, September 13, 2006 11:02 AM > To: Michael Gormley > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Access Rows in a Data Frame by Row Name > > Matrix-style indexing works for both

Re: [R] Access Rows in a Data Frame by Row Name

2006-09-13 Thread Tony Plate
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" wil

[R] Access Rows in a Data Frame by Row Name

2006-09-13 Thread Michael Gormley
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 HTM