I am trying to get around the strange overlap of stats::reorder vs Hmisc::reorder.
Without Hmisc loaded I get the result I want, i.e. an unordered factor:
> with(InsectSprays, reorder(spray, count, median))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
attr(,"scores")
A B C D E F
14.0 16.5 1.5 5.0 3.0 15.0
Levels: C E D A F B
Now after loading Hmisc the result is an ordered factor:
> library(Hmisc)
Loading required package: survival
Loading required package: splines
Attaching package: 'Hmisc'
The following object(s) are masked from 'package:survival':
untangle.specials
The following object(s) are masked from 'package:base':
format.pval, round.POSIXt, trunc.POSIXt, units
> with(InsectSprays, reorder(spray, count, median))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
Levels: C < E < D < A < F < B
In calling stats::reorder directly, I now for some reason get an ordered factor.
> with(InsectSprays, stats::reorder(spray, count, median))
[1] A A A A A A A A A A A A B B B B B B B B B B B B C C C C C C C C C C C C D D
[39] D D D D D D D D D D E E E E E E E E E E E E F F F F F F F F F F F F
Levels: C < E < D < A < F < B
Specifying, that I would need an unordered factor results in an error suggesting that stats::reorder is not used?
> with(InsectSprays, stats::reorder(spray, count, median, order = FALSE))
Error in FUN(X[[1L]], ...) : unused argument(s) (order = FALSE)
So the question really is how do I get an unordered factor with Hmisc loaded?