我之前发布了这个,但它太长了。我不确定如何迭代地将必要的数据附加到矩阵。任何帮助深表感谢。我的例子如下 -
set.seed(20430)
n = 1000
k = 3
fileA = rnorm(n)
fileB = rnorm(n)
fileC = rnorm(n)
positions = paste("randomPos_",rnorm(n),sep="")
betas <- cbind(fileA, fileB, fileC)
for(j in 1:k){
for(i in 1:n){
x[i,j] = (positions[i]*betas[j])
}
}
结果:
Error in positions[i] * betas[j] :
non-numeric argument to binary operator