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.
----- Original Message -----
From: eliza botto <eliza_botto at hotmail.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc:
Sent: Wednesday, March 6, 2013 6:26 AM
Subject: [R] combining column having same values
Dear useRs,
I have a matrix in the following form
[,1]? [,2]? [,3]? [,4]? [,5]? [,6]? [,7]? [,8]? [,9]? [,10]? [,11]? ? ? 1? ? ? 1? ? ? 3? ? ? 2? ? ? 3? ? ? 1? ? ? 1? ? ? 2? ? ? 3? ? ? 3? ? ? 2
and following is my desired output? (combining the column headers, having same values).
a<-1,2,6,7
b<-3,5,9,10
c<-4,8,11
Thanks in advance
Elisa ??? ??? ??? ? ??? ??? ?
??? [[alternative HTML version deleted]]
______________________________________________
R-help at 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.