How to call a function using the character string of the function name in R?

前端 未结 3 938
长发绾君心
长发绾君心 2020-12-08 04:02

I am trying to call a function with a given string of the function name.

E.g.

print(funcList)
[[1]]
`*`

[[2]]
sin

works:

3条回答
  •  佛祖请我去吃肉
    2020-12-08 04:34

    you could also use match.fun

    > functionlist <- list("*","sin")
    > f <- match.fun(functionlist[[1]])
    > f(5,6)
    [1] 30
    

提交回复
热议问题