|
发表于 2011-12-30 17:24:08
|
显示全部楼层
回帖奖励 +2 金钱
data<-as.matrix(read.table("h://lc.txt"));
> data;
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
[1,] 1 9 7 1 3 1 4 7 2 3
[2,] 3 5 2 6 2 3 9 1 3 5
[3,] 9 1 3 2 4 3 2 4 1 5
f<-factor(rep(1:5,each=2));
> f;
[1] 1 1 2 2 3 3 4 4 5 5
Levels: 1 2 3 4 5
sapply(1:3,function(y) as.numeric(sapply(1:5,function(x) paste( split(data[y,],f)[[x]],collapse =""))));
[,1] [,2] [,3]
[1,] 19 35 91
[2,] 71 26 32
[3,] 31 23 43
[4,] 47 91 24
[5,] 23 35 15
你会懂的。呵呵呵 |
|