The stacked order of ggplot columns ends with an unknown desc function

I am trying to reorder the levels in my stacked column (the order in which it fills the fill levels). The ggplot documentation shows this as straightforward:

# Use the order aesthetic to change stacking order of bar charts
w <- ggplot(diamonds, aes(clarity, fill = cut))
w + geom_bar()
w + geom_bar(aes(order = desc(cut)))

which seems to be needed by me, but when I try to run the above code, it produces this:

Error in eval (expr, envir, enc): could not find function "desc"

Is there another package I need to enable in order to get this feature, or is it now an obsolete way to do this that has been replaced? I tried reordering the factors in data.frame, but that does not change how geom_bar stacks them.

The documents I'm viewing (in RStudio) are for "[Package ggplot2 version 1.0.0 Index]"

thank

+4
2

desc() plyr, ggplot2, . library(plyr) .

+4

:

library(ggplot2)
library(dplyr)

w <- ggplot(diamonds, aes(clarity, fill = cut))
w + geom_bar()
w + geom_bar(aes(order = desc(cut)))
0

All Articles