vtable icon indicating copy to clipboard operation
vtable copied to clipboard

vtable returns factor levels sorted alphabetically and not as the levels function reports them,

Open MilosZarkovic opened this issue 1 year ago • 1 comments

vtable returns factor levels sorted alphabetically and not as the levels function reports them, e,g: vtable: 'Daily' 'Rarely' 'Weekly' levels: "Rarely" "Weekly" "Daily"

Is there a way to make vtable report levels the same as R function levels. Thanks Miloš

MilosZarkovic avatar Oct 13 '24 18:10 MilosZarkovic

Hi Milos, I cannot reproduce this issue. I get factor-order results for both vtable and sumtable. I wonder if somehow your variable is not stored as a factor despite having levels set? Can you share your code?

d = data.frame(A = factor(c('A','B','C'), levels = c('C','A','B')))
vtable::sumtable(d)
vtable::vtable(d)

NickCH-K avatar Oct 15 '24 18:10 NickCH-K