Dear R list

I have an m * n matrix P and a vector V of length n containing indices for
rows in P.
For each of the m columns I want to extract the value in the row specified
by V, and put these values into a new vector W of length n.
At present I am doing this with a for� loop, but I imagine there is a faster
way that doesn�t involve loops.
If anyone knows the way I would be most grateful.

Below is the code I am using at present-

for (i in 1:n){
W[i]<-P[V[i],i]}

Many thanks,
Dan Bebber
____________________________
Department of Plant Sciences
University of Oxford
South Parks Road
Oxford OX1 3RB
UK
Tel. 01865 275060
Fax. 01865 275074

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to