ex1 <- quote(X <- rnorm(10, mean=0.9, sd=4))
ex2 <- quote(Y <- rbeta(10, shape1=3, shape2=5))
f1 <- lapply(c(ex1, ex2), TreeHarp, quote_arg=TRUE)
# returns all function calls that begin with "r", like rnorm and rbeta.
# calls are returned as a list.
fapply(f1, extract_fn_call, combine =FALSE, pattern="^r.*")
# list is catenated.
fapply(f1, extract_fn_call, combine =TRUE, pattern="^r.*",
combiner_fn = function(x) {paste0(unlist(x), collapse=",")})
Run the code above in your browser using DataLab