Re: [R] Extracting from a matrix w/o for-loop

2006-07-29 Thread Adrian DUSA
Hi, On Friday 28 July 2006 20:21, Horace Tso wrote: > Unless there is another level of complexity that i didn't see here, > wouldn't it be a simply application of sapply as follow, > > sapply( 1:dim(M2)[[1]], function(x) M1[M2[x,1], M2[x,2]] ) Andy's previous answer involving matrix indexing (M1[

Re: [R] Extracting from a matrix w/o for-loop

2006-07-28 Thread Horace Tso
Unless there is another level of complexity that i didn't see here, wouldn't it be a simply application of sapply as follow, sapply( 1:dim(M2)[[1]], function(x) M1[M2[x,1], M2[x,2]] ) Hope this helps. Horace >>> "Camarda, Carlo Giovanni" <[EMAIL PROTECTED]> 7/28/2006 9:40 AM >>> Dear R-users,

Re: [R] Extracting from a matrix w/o for-loop

2006-07-28 Thread Liaw, Andy
Yes, by matrix indexing: R> M1[M2] [1] 1 2 13 15 8 R> v [1] 1 2 13 15 8 Andy From: Camarda, Carlo Giovanni > > Dear R-users, > > likely there is a simple solution for this problem, but I currently > cannot see it. > > I basically would like to get from a matrix values in particular > p