> # This assumes you have a parameter list which looks like this:
> # l: list(n = c(5, 10, 20),
> #         a = c(0.1, 0.2, 0.3),
> #         E = c(5,10),
> #         L = c(0.01, 0.025, 1))  etc...
> #
> #
> # indVec:c(n= 1, a=1, E=2, L=1)
> # The function selects the approproate sub-list by the name
> getParam <- function(indexVec,l){
>       n <- names(indexVec)    # get parameter names
>       ret <- c()        # create list to contain the parameter values
>       for (i in 1:length(indVec)){
>               para <- l[[ n[i] ]]    # get the right parameter
>               # and choose the value specified by indexVec
>               #Append the value to the list to be returned
>               ret <- c(ret, para[ indVec[i] ])
>       }       
>       return(ret)
> }

Oops, typo: make indexVec out of indVec :-/

-- 
GnuPG Key: 0x7340821E

______________________________________________
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.

Reply via email to