What does the following code denote about index updation?

DWQA QuestionsCategory: R LanguageWhat does the following code denote about index updation?
Editor Staff asked 9 months ago

What does the following code denote about index updation?
for (index in 1:3) {
index <- index * 2
print(index)
}

2 Answers
Editor Staff answered 9 months ago

In a for-loop the index is updated at the beginning of each iteration. Therefore,
reassigning the index symbol during one iteration doesn’t affect the following iterations.

Editor Staff answered 9 months ago

In a for-loop the index is updated at the beginning of each iteration. Therefore,
reassigning the index symbol during one iteration doesn’t affect the following iterations.