【发布时间】:2014-06-03 20:27:40
【问题描述】:
我需要对每两列求和 例如
x1 x2 x3 x4
12 2 3 7
1 4 6 5
我需要
X1 X2
14 10
5 11
我尝试了应用功能 我试过这个功能 mat 是一个矩阵
mat1=matrix()
for(i in 1:nrow(mat)){
for(j in 1:ncol(mat)){
mat1[i,j]=mat[j,i]+mat[j,i+1]
}}
【问题讨论】:
-
A5C1D2H2I1M1N2O1R2T1 的答案使用
split.default。相关:What is the algorithm behind R core'ssplitfunction?