df <- read.csv("melb_house_2.csv")
Is there a relationship between the number of bedrooms and bathrooms in a property?
p1 <- ggplot(df, aes(x = Bedroom, y = Bathroom))
p2 <- geom_point()
p1 + p2
Many properties share the same bedroom/bathroom count. A jitter plot reveals overlapping data points that the scatter plot hides.
p1 <- ggplot(df, aes(x = Bedroom, y = Bathroom))
p2 <- geom_jitter()
p1 + p2
How does price vary across different bedroom/bathroom combinations?
p1 <- ggplot(df, aes(x = Bedroom, y = Bathroom, color = Price))
p2 <- geom_jitter()
p1 + p2
Adjusting jitter width and height changes the clarity of the plot.
p2 <- geom_jitter(width = 0.3, height = 0.3)
p1 + p2
Descriptive labels, a clean theme, and legend placement improve readability.
p1 <- ggplot(df, aes(x = Bedroom, y = Bathroom, color = Price))
p2 <- geom_jitter(width = 0.3)
p3 <- labs(x = "Number of Bedrooms",
y = "Number of Bathrooms",
title = "Relationship Between Bedrooms, Bathrooms and Price")
p4 <- theme_bw()
p5 <- theme(legend.position = "top")
p1 + p2 + p3 + p4 + p5
Does the bedroom-bathroom-price pattern hold across all suburbs?
p6 <- facet_wrap(~Suburb)
p1 + p2 + p3 + p4 + p5 + p6
What is the overall trend between bedrooms and bathrooms?
p2 <- geom_jitter(width = 0.3, height = 0.3, alpha = 0.5)
p7 <- geom_smooth()
p1 + p2 + p3 + p4 + p5 + p6 + p7