Closed alinacherkas closed 2 months ago
Thanks, I'll see what I can do about fmean
. across()
is not exported because this would give a namespace conflict with dplyr
. I had though about calling it facross()
, but decided against it because it is unnecessary to use qualified names in this case, although I of course understand that this comes as a surprise.
This is now fixed.
Describe the bug
Consider a use case where functions from
collapse
are invoked using qualified calls, i.e.,collapse::function
. This is the preferred approach if one writes another package or just wants to keep the environment clean. Now, taking an example fromacross
:Scenario 1: Attach the package
This works:
Scenario 2: Qualified calls
This doesn't work:
Scenario 3: Qualified calls after exporting across
Let's modify
NAMESPACE
to addexport(across)
and rebuildcollapse
. This still doesn't work but the error is different:This is expected because throwing an error is, in fact, all that
collapse::across
does. Looking into the definition offsummarise
, one can notice that the heavy lifting is actually done bydo_across
, andacross
is just a call name. Enter scenario 4.Scenario 4: Qualified calls after replacing across with a dummy
This doesn't work, but the error is now related to
fmean
:So slightly modifying the above, one obtains a working solution:
In fact, defining across is not even needed:
Questions
In
dplyr
, for example, you can do both:This is possible because they check the calling environment in a different way.
While this works:
Not qualifying
across
seems odd.fmean
and related functions? As shown above,collapse::fmean
does not properly resolve.Steps/Code to Reproduce
Expected Results
Actual Results
If exported as is:
Session Info
P.S. Thank you for this useful and performant package!