#if for matrix
i<-10
i
y<-if (i<5){3} else {10}
y
for(i in 1:10){
+ print(i*i)
}
x<-matrix(1:30,nrow=5)
x
for(i in seq_len(nrow(x))){
for (j in seq_len(ncol(x))){
print(x[i,j]);
}
print(rep(i,nrow(x)))
}
生活、成长记录
#if for matrix
i<-10
i
y<-if (i<5){3} else {10}
y
for(i in 1:10){
+ print(i*i)
}
x<-matrix(1:30,nrow=5)
x
for(i in seq_len(nrow(x))){
for (j in seq_len(ncol(x))){
print(x[i,j]);
}
print(rep(i,nrow(x)))
}