How to pass some (but not all) further arguments with “…”

后端 未结 2 1254
轮回少年
轮回少年 2020-12-21 02:35

One of my in-progress functions calls grep() with value = TRUE hard-coded. I\'d like to pass all of the further arguments except <

2条回答
  •  忘掉有多难
    2020-12-21 03:24

    You can combine Curry with do.call:

    require(functional)
    f <- function(pattern, x, ...)
    {
      dots <- list(...)
      dots <- dots[!grepl('value', names(dots))]
      do.call(Curry(grep, pattern=pattern, x=x, value=TRUE), dots)
    }
    

    Curry provides the known arguments, and dots supplies everything other than "value" in ....

提交回复
热议问题