-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove legacy ccao::vars_dict attributes from README.Rmd code #4
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,27 +67,30 @@ Because our office (mostly) cannot observe individual condo unit characteristics | |
library(dplyr) | ||
library(tidyr) | ||
library(yaml) | ||
params <- read_yaml("params.yaml") | ||
library(httr) | ||
|
||
condo_params <- read_yaml("params.yaml") | ||
condo_preds <- condo_params$model$predictor$all | ||
|
||
res_params_text <- GET( | ||
"https://raw.githubusercontent.com/ccao-data/model-res-avm/master/params.yaml" | ||
) %>% | ||
content(as = "text") | ||
res_params <- read_yaml(text = res_params_text) | ||
res_preds <- res_params$model$predictor$all | ||
|
||
condo_unique_preds <- setdiff(condo_preds, res_preds) | ||
|
||
ccao::vars_dict %>% | ||
filter( | ||
var_is_predictor, | ||
!var_name_model %in% c("meta_sale_price") | ||
) %>% | ||
jeancochrane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
inner_join( | ||
as_tibble(params$model$predictor$all), | ||
as_tibble(condo_preds), | ||
by = c("var_name_model" = "value") | ||
) %>% | ||
filter( | ||
stringr::str_starts(var_name_model, "char_", negate = TRUE) | | ||
var_name_model %in% c("char_yrblt", "char_land_sf") | | ||
var_model_type == "condo", | ||
stringr::str_starts(var_name_model, "ind_", negate = TRUE) | ||
) %>% | ||
jeancochrane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
distinct( | ||
var_name_model, | ||
`Feature Name` = var_name_pretty, | ||
Category = var_type, | ||
Type = var_data_type, | ||
var_model_type | ||
) %>% | ||
mutate( | ||
Category = recode( | ||
|
@@ -106,13 +109,15 @@ ccao::vars_dict %>% | |
) | ||
) %>% | ||
mutate(`Unique to Condo Model` = ifelse( | ||
var_model_type == "condo" | | ||
var_name_model != "loc_tax_municipality_name" & ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit hacky here, but without this line the code will decide that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually a mistake, as both should be using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't think of a reason they should be different. I think you're correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I opened an issue for the res model fix here! ccao-data/model-res-avm#20 |
||
var_name_model %in% condo_unique_preds | | ||
`Feature Name` %in% | ||
c("Condominium Building Year Built", "Condominium % Ownership"), | ||
c("Condominium Building Year Built", "Condominium % Ownership") | ||
), | ||
"X", "" | ||
)) %>% | ||
arrange(desc(`Unique to Condo Model`), Category) %>% | ||
select(-var_model_type) %>% | ||
select(-var_name_model) %>% | ||
knitr::kable(format = "markdown") | ||
``` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: No need to do a GET or load
httr
,read_yaml()
can ingest directly from a URL.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh that's nice! Simplified in 7572d02 👍🏻