↧
Answer by akrun for How to repeat a for loop in R for n times?
If we want to repeat the for loop 'n' times, create a function with the for loopf1 <- function(data, ival) { for(i in head(seq_len(nrow(data)), -1)) { if(i > ival) { data$deltas[i] <-...
View ArticleHow to repeat a for loop in R for n times?
I am trying to repeat a for loop in R for a fixed number of times. Here is a sample of the code I want to repeatfor (i in 1:nrow(data)) { if (i>130){ data$deltas[i]=-((-data$p[i]))*data$alphas[i] }...
View Article