Skip to content

Commit

Permalink
Replace missing PPPs by MERs instead of with 1
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoch94 committed Oct 14, 2024
1 parent f06ed78 commit cdd05f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/adapt_source.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ adapt_source <- function(gdp, source, with_regions, replace_NAs, require_year_co
dplyr::arrange(.data$iso3c, .data$year) %>%
dplyr::select(-"gd")

# Replace missing MER and PPP values with US values (=1)
source_adapted <- source_adapted %>%
tidyr::replace_na(list("MER (LCU per US$)" = 1,
"PPP conversion factor, GDP (LCU per international $)" = 1))
# If there is no PPP data whatsoever for the country, use MERs
source_adapted <- source_adapted %>%
dplyr::mutate("PPP conversion factor, GDP (LCU per international $)" =
dplyr::if_else(is.na(.data$`PPP conversion factor, GDP (LCU per international $)`),
.data$`MER (LCU per US$)`,
.data$`PPP conversion factor, GDP (LCU per international $)`))

# If there is no deflator data whatsoever for the country, use US values
ec <- dplyr::group_by(source_adapted, .data$iso3c) %>%
Expand Down

0 comments on commit cdd05f4

Please sign in to comment.