R for循环示例

R for循环示例
for(i in 1:10){
  print(i)
}

for(i in seq(10)){
  print(i)
}

a <- list(1,2,4)
for(i in a){
  print(i)
}

for (year in c(2010,2011)){
  print(paste("The year is", year))
}

参考:https://www.r-bloggers.com/2015/12/how-to-write-the-first-for-loop-in-r/

posted @ 2021-07-01 20:17  船长博客  阅读(535)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!