Speed up the loop operation in R
Biggest problem and root of ineffectiveness is indexing data.frame, I mean all this lines where you use temp[,]. Try to avoid this as much as possible. I took your function, change indexing and here version_A dayloop2_A <- function(temp){ res <- numeric(nrow(temp)) for (i in 1:nrow(temp)){ res[i] <- i if (i > 1) { if ((temp[i,6] … Read more