I have a data frame with 30 columns numbered from 0 to 29.
I call stack on this data frame to plot a series of boxplots, one for each column number.
But instead of getting the boxplots in the sequence 0,1,2,3, … it prints 0,1,10,11..19, 2, 7, 8, 9.
In other words, i want the boxplots to appear in the same sequence of the columns, which
is natural.
I’m using boxplot(values ~ column, data = mydata).
I don’t want to fix that by changing the column names.
Is there another solution?
Thanks!
stackstores the column name as a factor,and the default order is alphabetic.
You can either fix the order once it has been tampered with,
or just use
meltinstead ofstack:the column order will be preserved.