Skip to content
Prev 269519 / 398502 Next

Passing a large amount of parameters to a function

You could use something like the following:

paramsList <- list(p1 = 1:10, p2 = -5:5, p3 = 5, p4 = 8)
params <- unlist(as.relistable(paramsList))

myFunc <- function (params) {
     params <- relist(params, skeleton = paramsList)
     p1 <- params$p1
     p2 <- params$p2
     p3 <- params$p3
     p4 <- params$p4
     ...
}

For another example have a look at the online help file of relist().

I hope it helps.

Best,
Dimitris
On 8/24/2011 9:28 AM, Eran Eidinger wrote: