How do I pass a missing argument to a function using do.call? The following does not work:
x <- array(1:9, c(3, 3))
do.call(`[`, list(x, , 1))
I expect this to do the same calculation as
x[,1]
>Solution :
you can use quote(expr=)
x <- array(1:9, c(3, 3))
do.call(`[`, list(x, quote(expr=), 1))
#> [1] 1 2 3
identical(x[,1], do.call(`[`, list(x, quote(expr=), 1)))
#> [1] TRUE
Created on 2022-04-20 by the reprex package (v2.0.1)
do.call([, alist(x,, 1)) also works