R/utils.R

Defines functions smart_select_year smart_select_iso3c

# Eager pipe. Used to make sure the messages of the elemental conversion are printed in the right order.
`%>e%` <- magrittr::pipe_eager_lexical

smart_select_iso3c <- function(gdp) {
  gdp %>%
    dplyr::select(tidyselect::vars_select_helpers$where(
      ~ (is.character(.x) || is.factor(.x)) &&
        all(nchar(as.character(.x)) == 3) &&
        all(.x == toupper(.x))
    )) %>%
    colnames()
}

smart_select_year <- function(gdp) {
  gdp %>%
    dplyr::select(tidyselect::vars_select_helpers$where(
      ~ is.numeric(.x) &&
        all(!is.na(.x)) &&
        all(nchar(as.character(.x)) == 4)
    )) %>%
    colnames()
}

Try the GDPuc package in your browser

Any scripts or data that you put into this service are public.

GDPuc documentation built on Sept. 11, 2024, 6:17 p.m.