Control Structures In R Programming - Study Mode

[#121] What is the purpose of the which() function in R?
Correct Answer

(B) To identify the positions of elements satisfying a condition

[#122] What is the output of the following R code: for (i in 1:5) { if (i %% 2 == 0) { print(i) } }
Correct Answer

(C) 2, 4

[#123] In R, what is the purpose of the repeat loop combined with break?
Correct Answer

(D) To exit the loop immediately

[#124] How is the switch() function different from if-else in R?
Correct Answer

(A) switch() is used for multiple conditions, if-else for two conditions

[#125] What is the role of the next statement in a loop in R?
Correct Answer

(C) To move to the next iteration of the loop