Hi, Do you want this? el<- matrix(1:100,ncol=20) set.seed(25) el1<- matrix(sample(1:100,20,replace=TRUE),ncol=1) indx<-sort(el1,index.return=TRUE)$ix[1:3]
list(el[,indx],sort(el1)[1:3]) #[[1]] # [,1] [,2] [,3] #[1,] 41 21 11 #[2,] 42 22 12 #[3,] 43 23 13 #[4,] 44 24 14 #[5,] 45 25 15 # #[[2]] #[1] 7 13 15 A.K. ________________________________ From: eliza botto <eliza_bo...@hotmail.com> To: "smartpink...@yahoo.com" <smartpink...@yahoo.com> Sent: Thursday, April 25, 2013 4:45 PM Subject: RE: [R] Distance matrices Combinations dear arun, I will see through it thoroughly if you give some 10 mins. Meanwhile can you please tell me that how we can change the following of your codes so that in "el1" we could see the values not the indexes?? thanks, Elisa el1<-matrix(o,ncol=1) indx<-sort(el1,index.return=F)$ix[1:3] list(el[,indx],indx) ______________________________________________ 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.