Skip to content

Commit

Permalink
Use verbatim region for recs w/o municipality
Browse files Browse the repository at this point in the history
  • Loading branch information
wkmor1 committed Oct 1, 2024
1 parent c0777da commit 56b4132
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 160 deletions.
8 changes: 8 additions & 0 deletions R/finbif_occurrence.R
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,8 @@ compute_region <- function(fb_occurrence_df) {

region_var <- var_names[["computed_var_region", vtype]]

region_verbatim <- var_names[["gathering.province", vtype]]

add <- attr(fb_occurrence_df, "include_new_cols", TRUE)

if (add && region_var %in% attr(fb_occurrence_df, "column_names", TRUE)) {
Expand All @@ -1420,6 +1422,12 @@ compute_region <- function(fb_occurrence_df) {

fb_occurrence_df[[region_var]] <- municipality[id, "region"]

fb_occurrence_df[[region_var]] <- ifelse(
is.na(fb_occurrence_df[[region_var]]),
fb_occurrence_df[[region_verbatim]],
fb_occurrence_df[[region_var]]
)

}

fb_occurrence_df
Expand Down
5 changes: 4 additions & 1 deletion R/finbif_records.R
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,10 @@ infer_computed_vars <- function(fb_records_obj) {
),
region = list(
vars = c("region", "stateProvince"),
v_names = "gathering.interpretations.finnishMunicipality"
v_names = c(
"gathering.interpretations.finnishMunicipality",
"gathering.province"
)
),
institution_code = list(
vars = c("institution_code", "institutionCode"),
Expand Down
Loading

0 comments on commit 56b4132

Please sign in to comment.