R/map_chr_hack.R

Defines functions map_chr_hack

Documented in map_chr_hack

#' Map given function, handle null as NA and flatten_chr()
#'
#' \lifecycle{deprecated}
#'
#' @details Use this function to extract elements with NAs from a list of lists
#' into a tibble.
#'
#' @param .x An interable data object
#' @param .f A function to map over the data
#' @param ... Extra arguments to `map()`
#' @author Jennifer Bryan https://github.com/jennybc/
#' @export
#' @family helpers
map_chr_hack <- function(.x, .f, ...) {
  purrr::map(.x, .f, ...) %>%
    purrr::map_if(is.null, ~NA_character_) %>%
    purrr::flatten_chr()
}
dbca-wa/wastdr documentation built on Nov. 20, 2022, 12:25 p.m.