Re: [R] indexing data.frame columns

2012-04-05 Thread Milan Bouchet-Valat
Le jeudi 05 avril 2012 à 12:40 -0700, Peter Meilstrup a écrit : > Consider the data.frame: > > df <- data.frame(A = c(1,4,2,6,7,3,6), B= c(3,7,2,7,3,5,4), C = > c(2,7,5,2,7,4,5), index = c("A","B","A","C","B","B","C")) > > I want to select the column specified in 'index' for every row of 'df', to

Re: [R] indexing data.frame columns

2012-04-05 Thread ilai
On Thu, Apr 5, 2012 at 1:40 PM, Peter Meilstrup wrote: > Consider the data.frame: > > df <- data.frame(A = c(1,4,2,6,7,3,6), B= c(3,7,2,7,3,5,4), C = > c(2,7,5,2,7,4,5), index = c("A","B","A","C","B","B","C")) > > I want to select the column specified in 'index' for every row of 'df', to > get > >

[R] indexing data.frame columns

2012-04-05 Thread Peter Meilstrup
Consider the data.frame: df <- data.frame(A = c(1,4,2,6,7,3,6), B= c(3,7,2,7,3,5,4), C = c(2,7,5,2,7,4,5), index = c("A","B","A","C","B","B","C")) I want to select the column specified in 'index' for every row of 'df', to get goal <- c(1, 7, 2, 2, 3, 5, 5) This sounds a lot like the indexing-by