tompkins <- read_csv("data/tompkins-home-sales.csv") |>
mutate(decade_built = (year_built %/% 10) * 10) |>
mutate(
decade_built_cat = case_when(
decade_built <= 1940 ~ "1940 or before",
decade_built >= 1990 ~ "1990 or after",
.default = as.character(decade_built)
)
)
mean_area_decade <- tompkins |>
group_by(decade_built_cat) |>
summarize(mean_area = mean(area))
mean_area_decade
# A tibble: 6 × 2
decade_built_cat mean_area
<chr> <dbl>
1 1940 or before 1872.
2 1950 1645.
3 1960 1874.
4 1970 1908.
5 1980 1852.
6 1990 or after 2226.