I am trying to create a box plot of the Baltimorecity Salaries open data:
> par(mar=c(16,4,1,1))
> boxplot(mydata$GROSSPAY ~ mydata$AGENCY, las=2)
I would like to display the boxes in order of of the total GROSSPAY of the AGENCY.
Is this possible with R? If so, how?
As this question was closed, I'm pasting an answer here:
mydata <- mydata[ ! is.na(mydata$GROSSPAY), ]
mydata$AGENCY <- with(mydata, reorder(AGENCY, GROSSPAY, sum))
par(las=2)
par(mar=c(16,4,1,1))
boxplot(mydata$GROSSPAY ~ mydata$AGENCY)