Meu barplot tem NA
no eixo x, portanto, retorna alguma imagem estranha dos meus dados eixo x deve ser meses como "jan fev mar .... DEC"
ggplot(x, aes(x = Month, y = x$freq)) + geom_bar(aes(fill=x$Sex), stat = "identity")
Aqui está o enredo resultante
Respostas:
0 para resposta № 1Tente o seguinte código:
# Sample dataframe
df <- data.frame(sex=c("Female","Female", "Male","Male"), month=c("Jan","Feb","Jan","Feb"), freq=c(130,160,160,175))
# Reorder the factor levels of a month column
df$month <- factor(df$month, levels = c("Jan","Feb"))
# ggplot
library("ggplot2")
ggplot(df, aes(x=month, y=freq, fill=sex)) + geom_bar(position="dodge", stat="identity")