I'm trying to change the order of the levels in my stacked bar plot (the order it stacks the fill levels). In the ggplot documentation it show this as being straight-forward with:
# 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 what I need but when I try to run the above code it produces this:
Error in eval(expr, envir, enclos) : could not find function "desc"
Is there another package I need to include to get this function or is this a now obsolete way to do this which has been replaced? I have tried re-ordering the factors in the data.frame but this does not change how geom_bar stacks them.
The docs I'm looking at (in RStudio) are for '[Package ggplot2 version 1.0.0 Index]'
thanks