问,各位大神:
R怎样将多个列向量合并成一个矩阵?(注:各个列向量为for循环产生,求如何用cbind(…)合成一个矩阵,这里列向量较多,不适合一个一个输入)
还请各大神不吝赐教,非常感谢~
附注:一小段程序:
c1=as.matrix(c(rep(0,0),rep(1,3),rep(0,15)))
c2=as.matrix(c(rep(0,3),rep(1,3),rep(0,12)))
c3=as.matrix(c(rep(0,6),rep(1,3),rep(0,9)))
c4=as.matrix(c(rep(0,9),rep(1,3),rep(0,6)))
c5=as.matrix(c(rep(0,12),rep(1,3),rep(0,3)))
c6=as.matrix(c(rep(0,15),rep(1,3),rep(0,0)))
Z=cbind(c1,c2,c3,c4,c5,c6)
需要要生成的是Z形式的矩阵;而ci用的是for循环来实现:
for(i in 1:n)
{
ci=as.matrix(c(rep(0,(i-1)*3),rep(1,3),rep(0,(n.tot-3i))))
}
不知Z如何用循环生成(Z=cbind(c1,c2,…,cn))



雷达卡




京公网安备 11010802022788号







