swang87 / fc

R package for function composition utilizing standard evaluation
0 stars 0 forks source link

Optional arguments are forced in fapply() #6

Closed swang87 closed 6 years ago

swang87 commented 6 years ago

Consider the following unintended behavior:

f  <- fapply(rnorm, mean=0) %>%
  fapply(matrix, ncol = 2)
f(200)

Instead of seeing a two-column matrix, we instead have just a 1 by 2 matrix. This is because the optional arguments in matrix() of nrow=1 is being forced. We should probably just omit optional arguments that are not specified when doing fapply().

Any reason we want to include "other_args"?

EDIT: I see we would need to include other_args that don't have default values set. In matrix(), this is problematic, because its primary argument 'data' already has a default value of NA. We need a clever way of figuring out which other arguments need to be specified, and omit the ones that have default values.