TransWikia.com

R: When do we use mean or median for the y axis in ggplot2 when doing analysis on property prices?

Cross Validated Asked by Chua S Yang on January 28, 2021

As mentioned in the title, I am not sure whether to use the median or mean function on prices of properties since prices of properties are on the y axis and my x-axis is for the years.

I have attached my images on the different graphs generated by using the mean and the median.

This is the mean graph and its code:

enter image description here

Plotly<-URA_data %>%
  mutate(Year = 2000 + as.integer(substring(Date.of.Sale, 1, 2))) %>%
  filter(Type.of.Sale %in% "Resale" & Type %in% "Condominium")%>%
  group_by(Year,Market.Segment ) %>%
  summarise(Price = mean(Price....))%>%
  ggplot(aes(Year, Price, color = Market.Segment)) + geom_line()+ geom_point()+
  labs(color="Segments")+
  ggtitle("Mean Property Prices by Market Segments ")+
  xlab("Year")+ylab("Price (Mean)")+
  theme(
    plot.title=element_text(color="red",size=14,face="bold.italic",hjust=0.5),
    axis.title.x=element_text(color="blue",size=14,face="bold"),
    axis.title.y=element_text(color="green",size=14,face="bold")
  )


library(plotly)

Graph<-ggplotly(Plotly)
Graph

This is the median graph and its code:

enter image description here

Plotly<-URA_data %>%
  mutate(Year = 2000 + as.integer(substring(Date.of.Sale, 1, 2))) %>%
  filter(Type.of.Sale %in% "Resale" & Type %in% "Condominium")%>%
  group_by(Year,Market.Segment ) %>%
  summarise(Price = mean(Price....))%>%
  ggplot(aes(Year, Price, color = Market.Segment)) + geom_line()+ geom_point()+
  labs(color="Segments")+
  ggtitle("Median Property Prices by Market Segments ")+
  xlab("Year")+ylab("Price (Median)")+
  theme(
    plot.title=element_text(color="red",size=14,face="bold.italic",hjust=0.5),
    axis.title.x=element_text(color="blue",size=14,face="bold"),
    axis.title.y=element_text(color="green",size=14,face="bold")
  )


library(plotly)

Graph<-ggplotly(Plotly)
Graph

Should I use mean or median of prices when doing analysis on property prices?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP