-1

I am currently doing a project and I want to find the average in the chart.

This is the code for ggplot2 that I wrote

ggplot(data = estates, aes(x=town, y=resale_price , fill=town)) +
  geom_bar(stat='identity',position = 'dodge') +
  ggtitle("Resale Price based on estate")+xlab("Town")+ylab("Resale price")+
  theme(plot.title = element_text(color = "red",size = 10,face = "bold.italic",hjust = 0.5),
        axis.title.x = element_text(color = "red",size = 8.5,face = "bold"),
        axis.title.y = element_text(color = "red",size = 8.5,face = "bold")
  )

Where do I put the mean function so that it will show on the bar chart?

Many thanks

1 Answers1

0

Similar answer posted here:

Boxplot show the value of mean

get your means like this:

mu <- aggregate(resale_price ~  town, estates, mean)

then add the text to ggplot with

+ geom_text()
Ruin Donas
  • 21
  • 5