I am learning ggplot2 and I want to plot a bar chart using the dataframe as is without converting it if possible.
Dataframe:
I want to plot it like this:
thanks,
I am learning ggplot2 and I want to plot a bar chart using the dataframe as is without converting it if possible.
Dataframe:
I want to plot it like this:
thanks,
I made some artificial data similar to yous. I updated to include the labels:
df=data.frame(cd=seq(0,4),October=c(128,68,29,21,75),November=c(90,80,15,11,80),December=c(55,151,28,7,79))%>%
melt(id.vars="cd",variable.name="Month")
df$cd<-as.factor(as.character(df$cd))
ggplot(df,aes(x=Month,y=value,fill=cd,label=value))+geom_col(position=position_dodge())+
geom_text(size = 4, position =position_dodge(1),vjust=-.5)
Off course you could change the grouping of your data, if for instance you would like x to represent cd and colors representing Month
ggplot(df,aes(x=cd,y=value,fill=Month,label=value))+geom_col(position=position_dodge())+
geom_text(size = 4, position =position_dodge(1),vjust=-.5)