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/
2024-01-16 08:42:52
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/