[Solved] how to apply a function on a data set?


I’m at least not quite sure whether I understood correct. Maybe a better question could improve the answers…

DF <- data.frame(Tree = c(4382, 4383, 4384, 5385, 4386), a = c(21.88, 13.93, 19.69, 20.02, 11.07), b = c(9.59, 12.95, 9.78, 8.23, 23.20), k = c(0.0538, 0.0811, 0.0597, 0.0489, 0.1276))
DOY <- c(1:365)
DF_new <-  data.frame(sapply(1:length(DF$Tree), function(x)(DF$a[x]*exp(-exp(DF$b[x]-DF$k[x]*DOY)))))
colnames(DF_new) <- DF$Tree

With sapply (apply, vapply,etc.) you can loop through vectors, lists, dataframe and so on. Without 1:length(DF$Tree) the values are used instead of the index.

solved how to apply a function on a data set?