AE 03: Duke Forest

Application exercise

Packages

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

Data

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!

Data Preparation

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.

Excercise 1

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!

  • Make histograms of the prices of houses in Duke Forest based on whether they have a garage.
  • Then, facet by `garage` and use different colors for the two facets.
  • Choose an appropriate binwidth and decide whether a legend is needed, and turn it off if not.
  • Include informative title and axis labels.
  • Finally, include a brief (2-3 sentence) narrative comparing the distributions of prices of Duke Forest houses that do and don’t have garages. Your narrative should touch on whe

Exercise 2

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!

  • Create a scatter plot to exploring the relationship between price and area, conditioning for year_built.
  • Use geom_smooth() with the argument se = FALSE to add a smooth curve fit to the data and color the points by year_built.
  • Include informative title, axis, and legend labels.
  • Discuss each of the following claims (1-2 sentences per claim). Your discussion should touch on specific things you observe in your plot as evidence for or against the claims.
    • Claim 1: Larger houses are priced higher.
    • Claim 2: Newer houses are priced higher.
    • Claim 3: Bigger and more expensive houses tend to be newer ones than smaller and cheaper ones.
# add code here

Add narrative here…

Important

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.