Load the Dataset

df <- read.csv("melb_house_2.csv")

4a: Scatter Plot - Bedrooms vs Bathrooms

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

4b: Jitter Plot

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

4c: Adding Price as a Third Variable

How does price vary across different bedroom/bathroom combinations?

p1 <- ggplot(df, aes(x = Bedroom, y = Bathroom, color = Price))
p2 <- geom_jitter()
p1 + p2

4d-e: Adjusting Jitter Width and Height

Adjusting jitter width and height changes the clarity of the plot.

p2 <- geom_jitter(width = 0.3, height = 0.3)
p1 + p2

4f-h: Labels, Theme, and Legend

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

4i: Faceting by Suburb

Does the bedroom-bathroom-price pattern hold across all suburbs?

p6 <- facet_wrap(~Suburb)
p1 + p2 + p3 + p4 + p5 + p6

4j-k: Adding Trend Lines

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