Skip to content

Commit

Permalink
add country_id to identifier variables in fetchdem
Browse files Browse the repository at this point in the history
  • Loading branch information
eteitelbaum committed Sep 13, 2024
1 parent 1055c6b commit 3a738ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: vdemlite
Title: A Lightwight Tool for Querying V-Dem Data
Version: 0.0.3.9000
Version: 0.0.4.9000
Authors@R:
person("Emmanuel", "Teitelbaum", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7089-0588"))
Expand Down
12 changes: 8 additions & 4 deletions R/fetchdem.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ fetchdem <- function(indicators = NULL,
# Select indicators if provided
if (!is.null(indicators)) {
filtered_data <- filtered_data |>
dplyr::select(country_name,
country_text_id,
year,
dplyr::select(.data$country_name,
.data$country_id,
.data$country_text_id,
.data$year,
# some indicators from codebook not available in vdem,
# so we use `any_of` to avoid errors
any_of(indicators))
Expand All @@ -119,7 +120,10 @@ fetchdem <- function(indicators = NULL,
return(filtered_data)
} else {
long_data <- filtered_data |>
tidyr::pivot_longer(cols = -c(country_name, country_text_id, year),
tidyr::pivot_longer(cols = -c(.data$country_name,
.data$country_id,
.data$country_text_id,
.data$year),
names_to = "indicator",
values_to = "value")
return(long_data)
Expand Down

0 comments on commit 3a738ff

Please sign in to comment.