[R] dynamically creating functions in r

honeyoak honeyoak at gmail.com
Wed Oct 5 16:57:25 CEST 2011


it is possible to dynamically create functions in R using lists? what I want
to do is something like this:

      a = list()
      for (i in 1:10) a[[i]] = function(seed = i) runif(seed)

so that when I call a[i] I get random draws 1,2,....i unfortunately R only
uses the last i . I would also like to know if there is a run-all function
without explicitly looping or using lapply. for example if I have a list 'b'
of functions if I called

      run-all(b)

all the functions in list 'b' would be run

thanks.

--
View this message in context: http://r.789695.n4.nabble.com/dynamically-creating-functions-in-r-tp3874767p3874767.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list