My barplot has NA
in x-axis therefore it returns some weird image of my data
x-axis should be months like "Jan Feb Mar .... DEC"
ggplot(x, aes(x = Month, y = x$freq)) + geom_bar(aes(fill=x$Sex), stat = 'identity')
Here is the resulting plot
Try the following code:
# 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")
x$
– rawr