有如下的程序:
x<- 1;
y<- matrix(0,10,10)
y[1,]<- c(x,rep(0,9))
for (n in 2:10){
for (i in 2:n){
x<- c(x,0)+c(0,x)
}
y[n,]<- c(x,rep(0,(10-n)))
}
y
运行显示:Error in y[n, ] <- c(x, rep(0, (10 - n))) : number of items to replace is not a multiple of replacement length.
我目前猜测是 (i in 2:n)出了问题,请大神指教