Re: [R] combining column having same values

2013-03-06 Thread Rui Barradas
Hello, Try x <- scan(text = " 1 1 3 2 3 1 1 2 3 3 2") sapply(unique(x), function(.x) which(x == .x)) Hope this helps, Rui Barradas Em 06-03-2013 11:26, eliza botto escreveu: Dear useRs, I have a matrix in the following form [,1] [,2]

Re: [R] combining column having same values

2013-03-06 Thread arun
Hi, Try this: mat1<- as.matrix(read.table(text=" 1  1  3  2  3  1  1  2  3  3  2 ",sep="",header=FALSE))  res<-lapply(1:3,function(i) which(mat1==i))  names(res)<- c("a","c","b")  res #$a #[1] 1 2 6 7 #$c #[1]  4  8 11 #$b #[1]  3  5  9 10 A.K. - O

Re: [R] combining column having same values

2013-03-06 Thread ONKELINX, Thierry
Dear Eliza, You question is not very clear. I think you are looking for the which() function. Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Klin