fct_cross()
orders levels by second factor before the first factor
#360
Labels
bug
an unexpected problem or unintended behavior
It seems a bit counter-intuitive to me that the crossed factor levels are ordered, for e.g. in the case of 2 inputs, by the second factor levels before the first factor levels.
In the reprex below, I would have expected
fct_cross(f1, f2)
to have its levels ordered asa4:b4 a3:b3 a2:b2 a1:b1
because levels off1
area4 a3 a2 a1
. Instead, the new levels are ordered by the levels off2
so we seea1:b1
as the first level.I also understand that this is because of how
expand.grid()
works, but I was hoping to select rows from the output data.frame after sorting the columns from Var1 to VarN.Created on 2024-01-17 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: