Dots (...) with variable title

3

I need to run a function of type

f <- function(...) {
  l <- list(...)
  l[["hortela"]]
}

x <- 'hortela'

If we do

f(hortela = 1)

We have the result 1 , which is what we expect.

How do I call f() using x instead of writing hortela manually?

PS: I do not want to change the f() .

    
asked by anonymous 27.02.2017 / 17:10

1 answer

2

I was able to resolve using do.call and a named list.

do.call(f, setNames(list(1), x))

Does the work.

    
27.02.2017 / 18:44