Getting a function name as a string

后端 未结 8 1295
半阙折子戏
半阙折子戏 2020-12-01 03:18

Say I have a bunch of functions, each with something likeMyFunction.1, etc. I want to pass these functions into another function, which prints out a small repo

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 03:51

    You can get the unevaluated arguments of a function via match.call. For example:

    > x <- function(y) print(match.call()[2])
    > x(lm)
    lm()
    

提交回复
热议问题