【发布时间】:2011-12-12 13:26:31
【问题描述】:
这可能是一个非常简单的问题,但我对 R 很陌生。我有一个 for 循环,
holder<-rep(0,3)
for(i in 1:3) {
apple<-c(i+1, i*2, i^3)
holder[i]<-apple
}
我收到警告消息:
Warning messages:
1: In holder[i] <- apple :
number of items to replace is not a multiple of replacement length
2: In holder[i] <- apple :
number of items to replace is not a multiple of replacement length
3: In holder[i] <- apple :
number of items to replace is not a multiple of replacement length
所以我尝试将 holder 设置为矩阵,而不是向量。但我无法完成它。任何建议将不胜感激。
最好的,
詹姆斯
【问题讨论】: