diff --git a/R/dg_call.R b/R/dg_call.R index 647a209..bd00d4e 100644 --- a/R/dg_call.R +++ b/R/dg_call.R @@ -176,7 +176,8 @@ dg_call <- function(region_id = NULL, # ## This is an if statement that handles when we need to get more info on a substat and its parameters if (!is.null(substat_name)) { - # add_substat_info <- purrr::possibly(add_substat_info, otherwise = NULL) + ## TODO: This is necessary because Travis (for some reason) sometimes treats API results as empty + add_substat_info <- purrr::possibly(add_substat_info, otherwise = NULL) api_results <- add_substat_info( api_results, diff --git a/R/helpers_call_results.R b/R/helpers_call_results.R index 21af323..faf2a3c 100644 --- a/R/helpers_call_results.R +++ b/R/helpers_call_results.R @@ -134,9 +134,14 @@ clean_ar <- function(raw) { purrr::map(~purrr::discard(.x, is.list)) %>% purrr::set_names(id_dat$id) %>% purrr::map_dfr(~ .x %>% tibble::as_tibble(), .id = "id") %>% - dplyr::left_join(id_dat, by = "id") %>% - cbind(source_dat) %>% - tibble::as_tibble() + dplyr::left_join(id_dat, by = "id") + + ## TODO: This is necessary because Travis (for some reason) sometimes thinks source_dat is empty + if (!(nrow(source_dat)==0)) { + final <- final %>% + cbind(source_dat) %>% + tibble::as_tibble() + } return(final) @@ -192,7 +197,7 @@ add_substat_info <- function(api_results, if (!all_regions) { suppressMessages( api_results <- api_results %>% - dplyr::left_join(meta_info) + dplyr::left_join(meta_info, by = substat_name_) ) if (!is.null(substat_name)) { @@ -218,7 +223,7 @@ add_substat_info <- function(api_results, } else { suppressMessages( api_results <- api_results %>% - dplyr::left_join(meta_info) %>% + dplyr::left_join(meta_info, by = substat_name_) %>% dplyr::select(-substat_name) %>% dplyr::mutate(year_id = paste0(year, "_", id)) # )