Warning: package 'tidyr' was built under R version 4.4.1
Warning: package 'airports' was built under R version 4.4.1
Warning: package 'cherryblossom' was built under R version 4.4.1
We will be using the Duke forest data set in the open intro package.
Do your own investigation to get to know the data. How many observations does it have? How many variables are measured? Go ahead and do a glimpse!
One of the questions in this AE asks about garages - notice that this is not a variable in the data set. I am adding code that creates a categorical variable called garage
that has two levels: Garage
or No garage
. Our new variable equals "Garage"
if the word "Garage"
is detected in the parking
variable and equals "No garage"
if not.
You do not need to understand this code yet - we will learn how to write things like this in the coming days! For now, just run the code!
duke_forest = duke_forest |>
mutate(garage = if_else(str_detect(parking, "Garage"), "Garage", "No garage"))
What did this do?
Go ahead and look at the data again to see the change.
Suppose you’re helping some family friends who are looking to buy a house in Duke Forest.
As they browse Zillow listings, they realize some houses have garages and others don’t, and they wonder: **Does having a garage make a difference?* *
Luckily, you can help them answer this question with data visualization!
It’s expected that within any given market, larger houses will be priced higher. It’s also expected that the age of the house will have an effect on the price. However in some markets new houses might be more expensive while in others new construction might mean “no character” and hence be less expensive. So your family friends ask: “In Duke Forest, do houses that are bigger and more expensive tend to be newer ones than those that are smaller and cheaper?”
Once again, data visualization skills to the rescue!
price
and area
, conditioning for year_built
.geom_smooth()
with the argument se = FALSE
to add a smooth curve fit to the data and color the points by year_built
.# add code here
Add narrative here…
Now is a good time to render, commit, and push. Make sure that you commit and push all changed documents and your Git pane is completely empty before proceeding.