我的程序中以前工作的 for 循环都没有按预期运行。我想知道我是否对 RStudio 环境/配置做了一些操作来打破 for 循环?...或者也许,我在这里缺少一些非常基本的东西?
考虑一个基本的 for 循环示例,例如
for (year in 2010:2015){
print(paste("The year is", year))}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,即使这个循环也没有向我的控制台返回任何内容。现在,考虑一个基本的 while 循环,比如说
count <- 0
while (count <10) {
print(count)
count = count +1}
Run Code Online (Sandbox Code Playgroud)
这个 while 循环返回预期的
[1] 0
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
[1] 9
Run Code Online (Sandbox Code Playgroud)