R语言–条件-循环

#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)))
}