I have some code where it is more convenient to call fix
via do.call
, rather than directly. Any old data frame will work for this example:
dfr <- data.frame(x = 1:5, y = letters[1:5])
The obvious first attempt is
do.call("fix", list(dfr))
Unfortunately, this fails with
Error in fix(list(x = 1:5, y = 1:5)) : 'fix' requires a name
So, we give it a name:
do.call("fix", list(dfr = dfr))
This time it fails with
Error in is.name(subx) : 'subx' is missing
For the record, edit
doesn't work either.
dfr <- do.call("edit", list(dfr = dfr))
Can anyone think of a sensible workaround, please?
EDIT: Upon reflection, I'd forgotten that fix
always dumps its answer into the global environment, which is fine for test examples, but not so good for use with functions. Joshua's excellent workaround doesn't extend to use with edit
.
For bonus points, how do you call edit
via do.call
?