crossing()
adds missing factor levels (either a bug or a documentation issue)
#1526
Labels
crossing()
adds missing factor levels (either a bug or a documentation issue)
#1526
When using
crossing()
with a factor that does not have all levels present, it inserts the missing levels. My guess is that this is an intentional feature and the documentation should clarify it. When I was usingcrossing()
the expansion of missing levels was unexpected since it added values that were not in the combination of inputs.The observed behavior is below, and I expected the second behavior in both cases.
I think that the documentation clarification that would have made the behavior expected would be the following:
Here, add "and the
nesting()
andcrossing()
helpers" after "complete()
":tidyr/R/expand.R
Lines 36 to 38 in ad62841
And, in the
expand_grid()
documentation, point back to the fact that it usesexpand()
. Perhaps adding something like the following to the details section of the docs ofexpand_grid()
: "expand_grid()
usesexpand()
to generate all combinations.Created on 2023-10-28 with reprex v2.0.2
If helpful, I can make the documentation PR.
The text was updated successfully, but these errors were encountered: