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 as a4:b4 a3:b3 a2:b2 a1:b1 because levels of f1 are a4 a3 a2 a1. Instead, the new levels are ordered by the levels of f2 so we see a1: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.
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