I want to generate specific gamma distribution functions, given fixed parameters. This is I have k, and theta, say
k <- 32.2549 # shape theta <- 26.32809 # scale # I have an auxiliary function that produces funcions according to # a given character (this is to have either dgamma, pgamma or qgamma) # for the specific parameters given above: faux <- function(c) { function (x) get(paste0(c,"gamma"))(x,k,scale=theta) } # So I can have, for instance, dgamma, and pgamma with dff <- faux("d") pff <- faux("p") dff(1000) ## [1] 0.001433138 pff(1000) ## [1] 0.844305 Now, if I try to produce both functions in one shot with lapply, the thing doesn't work, see ffs <- lapply(c("d", "p"), faux) ffs[[1]](1000) ## [1] 0.844305 ffs[[2]](1000) ## [1] 0.844305 The two produced functions are the very same and correspond to pgamma!! Maybe I'm missing something. Do you have any idea? Thanks, -Sergio. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.