Hello R-users

I have a situation like this

x=c(1,3,2)

y=data.frame("a"=1:3, "b"=4:6, "c"=7:9)*2

So we have

> t(t(x))
     [,1]
[1,]    1
[2,]    3
[3,]    2

And

> y
  a  b  c
1 2  8 14
2 4 10 16
3 6 12 18

I would like to obtain a vector with number taken from the data.frame: x is 
needed as row index 

With c(1,3,2), in this case the ouput should be

2
16
12

I've tried a little bit with apply, but unsuccessfully.

Thank you

______________________________________________
R-help@r-project.org 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.

Reply via email to