I would like to flatten this list of arguments
args <- list(
a = 1,
b = "2",
list = list(c = 3, d = list(d1 = 5, d2 = 6)),
e = data.frame(e1 = c("a", "b"), e2 = c(7, 8))
)
on this
args <- list(
a = 1,
b = "2",
c = 3,
d = list(d1 = 5, d2 = 6),
e = data.frame(e1 = c("a", "b"), e2 = c(7, 8))
)
Because I need get work this function call
g <- function(x, y, ...){
do.call(f, x, y, ...)
}
g(x = x1, y = y1, args)
That does not work:
reduce(
.x = args,
.f = function(x) {
ifelse(
is.list(x),
lapply(x, `[[`),
x
)
}
)
that throws
Error in fn(out, elt, ...) : unused argument (elt)