Extract names of dataframes passed with dots

后端 未结 2 1510
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 03:27

One can use deparse(substitute()) combination to extract the parameter name inside the function like this function

names_from_dots <- functio         


        
2条回答
  •  死守一世寂寞
    2020-12-11 03:57

    I wouldn’t use substitute here at all, it works badly with ...1. Instead, you can just capture the unevaluated dots using:

    dots = match.call(expand.dots = FALSE)$...
    

    Then you can get the arguments inside the dots:

    sapply(dots, deparse)
    

    1 Part of the reason is, I think, that substitute does completely different things when called with (a) an argument (which is a “promise” object) or (b) another object. ... falls somewhere in between these two.

提交回复
热议问题