Lead Data Scientist Question:

Explain me for loop control statement in R?

Tweet Share WhatsApp

Answer:

A loop is a sequence of instructions that is repeated until a certain condition is been reached. for, while and repeat, with the additional clauses break and next are used to construct loops.

For Example-

It is executed a known number of times for a block is been contained within curly braces.

x = c(1,2,3,4,5)
for(i in 1:5){
print(x[i])
}
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5

Download Lead Data Scientist PDF Read All 60 Lead Data Scientist Questions
Previous QuestionNext Question
Do you know what is the difference between rnorm and runif functions?Tell me you develop a big data model, but your end user has difficulty understanding how the model works and the insights it can reveal. How do you communicate with the user to get your points across?