[R] combining column having same values
Rui Barradas
ruipbarradas at sapo.pt
Wed Mar 6 16:17:18 CET 2013
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] [,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.
>
More information about the R-help
mailing list