R/NA_explicit_.R

options( NA_explicit_ = "(NA)" ) 

#' NA_explicit_
#'
#' Default replacement for missing values in categorical vectors.
#' 
#' @details 
#' 
#' `NA_explicit_` is used as a default replacement for categorical vectors. 
#' It is an active binding to `getOptions('NA_explicit_')` and is exported
#' to the callers namespace. 
#' 
#' To change the value of `NA_explicit` use:
#' ```
#' options( NA_explicit = new_value )
#' ``` 
#' You cannot directly set `NA_explicit_``
#' 
#' @seealso 
#' 
#'  - [na_explicit()]
#'  - [na_replace()]
#' 
#' @md
#' @export

NA_explicit_ <- 
  makeActiveBinding(
      "NA_explicit_"
    , function(x) {
        val <- getOption("NA_explicit_")
        # val <- structure(val, class = c("NA_explicit_", class(val)))
        val
      }
    , sys.frame( sys.nframe() )
  )


#' #' @rdname NA_explicit_
#' #' @export 
#' print.NA_explicit_ <- function(object) print( as.character( object ) ) 
#' 
#' #' @rdname NA_explicit_
#' #' @export
#' show.NA_explicit_ <- function(object) show( as.character( object ) )
decisionpatterns/na.actions documentation built on Aug. 25, 2020, 8:04 p.m.