Code
fhfa %>%
group_by(hpi_type) %>%
summarise(Nobs = n()) %>%
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| hpi_type | Nobs |
|---|---|
| traditional | 115990 |
| non-metro | 5358 |
| distress-free | 1560 |
| developmental | 223 |
Data
fhfa %>%
group_by(hpi_type) %>%
summarise(Nobs = n()) %>%
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| hpi_type | Nobs |
|---|---|
| traditional | 115990 |
| non-metro | 5358 |
| distress-free | 1560 |
| developmental | 223 |
fhfa %>%
group_by(hpi_flavor) %>%
summarise(Nobs = n()) %>%
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| hpi_flavor | Nobs |
|---|---|
| all-transactions | 82201 |
| purchase-only | 26500 |
| expanded-data | 14430 |
fhfa %>%
group_by(hpi_type, hpi_flavor) %>%
summarise(Nobs = n()) %>%
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| hpi_type | hpi_flavor | Nobs |
|---|---|---|
| traditional | all-transactions | 76730 |
| traditional | purchase-only | 24830 |
| traditional | expanded-data | 14430 |
| non-metro | all-transactions | 5358 |
| distress-free | purchase-only | 1560 |
| developmental | all-transactions | 113 |
| developmental | purchase-only | 110 |
fhfa %>%
group_by(level) %>%
summarise(Nobs = n()) %>%
arrange(-Nobs) %>%
{if (is_html_output()) print_table(.) else .}| level | Nobs |
|---|---|
| MSA | 85956 |
| State | 28512 |
| USA or Census Division | 8440 |
| Puerto Rico | 223 |
fhfa %>%
group_by(place_id, place_name) %>%
summarise(Nobs = n()) %>%
arrange(-Nobs) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}fhfa %>%
filter(frequency == "quarterly",
hpi_type == "traditional",
hpi_flavor == "all-transactions",
place_id %in% c("19740", "31084", "29820")) %>%
mutate(month = (period - 1)*3 + 1,
month = str_pad(month, 2, pad = "0"),
date = paste0(yr, "-", month, "-01") %>% as.Date) %>%
select(date, place_name, place_id, index_nsa) %>%
ggplot + theme_minimal() + xlab("") + ylab("") +
geom_line(aes(x = date, y = index_nsa, color = place_name)) +
scale_x_date(breaks = seq(1920, 2025, 5) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
scale_y_log10(breaks = c(seq(0, 500, 50), seq(10, 50, 10))) +
theme(legend.position = c(0.25, 0.8),
legend.title = element_blank())