Gerrit Draisma
2013-Aug-25 15:23 UTC
[R] how to combine apply and which or alternative ways to, do so
Ha Guillaume,
Is this what you are looking for?
#---------------
x1<-sample(1:10,5,replace=FALSE)
x2<-sample(1:10,100,replace=TRUE)
#This
tapply(x1,1:5,FUN=function(i){which(x2==i)})
#or this
tapply(x1,x1,FUN=function(i){which(x2==i)})
#---------------
Gerrit