Getting names from … (dots)

前端 未结 2 407
轮回少年
轮回少年 2021-01-02 20:28

In improving an rbind method, I\'d like to extract the names of the objects passed to it so that I might generate unique IDs from those.

I\'ve tried

2条回答
  •  暖寄归人
    2021-01-02 20:47

    Using the guidance here How to use R's ellipsis feature when writing your own function?

    eg substitute(list(...))

    and combining with with as.character

    rbind.test <- function(...) {
      .x <-  as.list(substitute(list(...)))[-1]
      as.character(.x)
     }
    

    you can also use

    rbind.test <- function(...){as.character(match.call(expand.dots = F)$...)}
    

提交回复
热议问题