R/negative_to_na.R

Defines functions zero_to_na negative_to_na

Documented in negative_to_na zero_to_na

#' Functions to replace values with NA
#' 
#' @param x Input vector
#' 
#' @author Shona Wilde
#' 
#' @return Vector of same length as x.
#' 
#' @export


negative_to_na <- function(x) {
  
x <- ifelse(x < 0, NA, x)  

return(x)

}


#' @rdname negative_to_na
#' @export
zero_to_na <- function(x) {
  
  x <- ifelse(x == 0, NA, x)
  
  return(x)
  
}
shonawilde/shonarrr documentation built on Jan. 29, 2025, 1:27 a.m.