Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用cbind循环有什么诀窍吗?_R_Loops_Matrix_Vector_Cbind - Fatal编程技术网

R 使用cbind循环有什么诀窍吗?

R 使用cbind循环有什么诀窍吗?,r,loops,matrix,vector,cbind,R,Loops,Matrix,Vector,Cbind,我有87个长度为4096的向量。比如说, > head(d[[1]]$x) [1] 1.676094 1.676323 1.676551 1.676780 1.677008 1.677237 我想把这些向量连接成一个矩阵,每个向量占据一列。因为单独绑定它们很好 Dscbind需要两个或多个参数。你能试试吗 Ds<-c() for(i in 1:87){ Ds<-cbind(Ds,d[[i]]$x) } DsWorks。非常感谢。 Error in Ds[[i]

我有87个长度为4096的向量。比如说,

> head(d[[1]]$x)
[1] 1.676094 1.676323 1.676551 1.676780 1.677008 1.677237
我想把这些向量连接成一个矩阵,每个向量占据一列。因为单独绑定它们很好


Ds
cbind
需要两个或多个参数。你能试试吗

Ds<-c() 
for(i in 1:87){
     Ds<-cbind(Ds,d[[i]]$x) 
}

DsWorks。非常感谢。
Error in Ds[[i]] <- cbind(d[[i]]$x) : 
  more elements supplied than there are to replace
Ds<-c() 
for(i in 1:87){
     Ds<-cbind(Ds,d[[i]]$x) 
}