【发布时间】:2014-03-02 09:13:05
【问题描述】:
我是 R 新手。我想使用 cbind 用我的 for 循环的结果填充一个空矩阵。我的问题是,如何消除矩阵第一列中的 NA。我在下面包含我的代码:
output<-matrix(,15,) ##generate an empty matrix with 15 rows, the first column already filled with NAs, is there any way to leave the first column empty?
for(`enter code here`){
normF<-`enter code here`
output<-cbind(output,normF)
}
输出是我期望的矩阵。唯一的问题是它的第一列充满了 NA。如何删除这些 NA?
【问题讨论】:
-
在 R 中这是一个非常糟糕的主意。不断增长的结构使代码非常缓慢。