R/set_chr.R

Defines functions set_chr

Documented in set_chr

#' set character
#'
#' @param .data dataframe
#' @param ... tidyselect. Default selection: none
#'
#' @return dataframe
#' @export
#'
#' @examples
#'
#' iris %>%
#' tibble::as_tibble() %>%
#' set_chr(tidyselect::everything())
#'
set_chr <- function(.data, ...){

  .data %>% select_otherwise(...) -> cols


  .data %>%
    dplyr::mutate(dplyr::across(tidyselect::any_of(cols), .fns = as.character))
}

Try the framecleaner package in your browser

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

framecleaner documentation built on May 29, 2024, 1:59 a.m.