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

前端 未结 3 928
长发绾君心
长发绾君心 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:53

    See documentation for do.call.

    A quick demonstration:

    do.call("rnorm", list(100, 0, 1))
    

    first parameter can be a string literal, or R object, and the second one is list of arguments that are to be matched with provided function formal arguments.

提交回复
热议问题