R: using a list for ellipsis arguments

前端 未结 1 622
無奈伤痛
無奈伤痛 2020-12-29 11:28

I have run into a situation where I need to take all the extra arguments passed to an R function and roll them into an object for later use. I thought the previous question

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 12:03

    How about

    newmean <- function(X, ...){
      args <- as.list(substitute(list(...)))[-1L]
      z<-list(X)
      z<-c(z,args)
      do.call(mean,z)
    }
    

    0 讨论(0)
提交回复
热议问题