Reputation: 299
I have a data frame named MyData
. Let's say it looks like this:
GreekMonth <- c("Ir","Fe","Mr","Ar","Ma","In","Il","Au","Se","Ok","No","De")
SomeValue <- c(rep(c(1,3,5),4), rep(c(2,4,6),4), rep(c(7,8,9),4))
MyData <- data.frame(MONTHS=rep(GreekMonth,3), MY_VALUE=SomeValue)
I tried to make a box-plot for each month. So I wrote:
library(ggplot2)
MyBox <- ggplot(MyData, aes(x=MONTHS, y=MY_VALUE))
MyBox + geom_boxplot()
Of course months are ordered alphabetically.
So, I wrote:
MyData$MONTHS <- factor(MyData$MONTHS, labels = GreekMonth)
and then:
MyBox2 <- ggplot(MyData, aes(x=MONTHS, y=MY_VALUE))
MyBox2 + geom_boxplot()
As you can see, months are ordered correctly, but with the wrong values.
What can I do?
Upvotes: 0
Views: 54