Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205793

R: convert elements of list into expression from function input

$
0
0

I am writing a function, where the inputs are arguments and name of another function. I would like to convert these arguments and function name into an unevaluated expression or call. For example, if this is the call to the function:

huh_fun(
  data = mtcars
  method = lm,
  formula = hp ~ mpg,
  method.args = list(weights = drat, subset = rep(TRUE, 32)) # list of additional arguments
)

I would like the function to return the following expression/call, unevaluated:

lm(hp ~ mpg, data = mtcars, weights = drat, subset = rep(TRUE, 32))

I've had success quoting the data=, method=, and formula= arguments and combining them into a call. But cannot figure out how to quote the method.args= argument, and add the list elements into function arguments. Any and all pointers are appreciated. Thank you~


Viewing all articles
Browse latest Browse all 205793

Trending Articles