x <- data.table(y = letters[1:4], x1990 = c(1,1,1,2), x1991 = c(2,1,1,1), x1992 = c(3,3,3,0.5), x1993 = c(5,2,2,4), x1994 = c(7,3, 5, NA_real_), x1995 = c(9, 8, 10,1))
if applied growth.ls to year columns (x1990: x1995)
apply(x[, paste0("x", 1990:1995), with = FALSE], 1, growth.ls)
# [1] 56.88514 53.77536 58.00203 NA
what if x has 1.5 million rows? what is the best way to calculate a new column "growth" rather than using apply.
I do not mind use any package since it is helping me delivered my work.
Thanks in advance