y***6 发帖数: 46 | 1 Hi all,
I am new to R and hope I can get some help here.
Say I have a matrix A as below
A<-[0 0 1, ->1st row
0 1 0, ->2nd row
0 0 1, ->3rd row
1 0 0] ->4th row
Now rows of A are considered to be factors, i.e. "001","010","100" in this
case. The output matrices B and C are desired,
B<-[001 2,->1st row
010 1,->2nd row
100 1]->3rd row
| t**i 发帖数: 688 | 2 paste(A[1,], collapse=TRUE) | D*******a 发帖数: 207 | | D******n 发帖数: 2836 | 4 B=apply(A,1,function(x)(paste(x,collapse="")));
B=data.frame(table(B));
【在 D*******a 的大作中提到】 : data.frame(table(A))
| y***6 发帖数: 46 | 5 I am amazed! Thanks a lot!! | y***6 发帖数: 46 | 6 Only the code given by Da Shagen is correct. I appreciate it. |
|