R/utils-pipe.R

Defines functions na_if_numeric na_if_character

#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL


na_if_character <- function(df, val) {
  dplyr::mutate(df, dplyr::across(where(is.character), ~ na_if(.x, val)))
}
na_if_numeric <- function(df, val) {
  dplyr::mutate(df, dplyr::across(where(is.numeric), ~ na_if(.x, val)))
}

Try the SwimmeR package in your browser

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

SwimmeR documentation built on March 31, 2023, 8:27 p.m.