R/coerce_nans.R

Defines functions coerce_nans.matrix coerce_nans.list coerce_nans

#' @noRd
coerce_nans <- function(x, to){
 UseMethod('coerce_nans')
}

#' @noRd
coerce_nans.list <- function(x, to){

 lapply(x, coerce_nans, to = to)

}
#' @noRd
coerce_nans.factor <-
 coerce_nans.integer <-
 coerce_nans.double <-
 coerce_nans.array <-
 coerce_nans.matrix <- function(x, to){

 if(any(is.nan(x))){
  x[is.nan(x)] <- to
 }

 x

}
bcjaeger/aorsf documentation built on April 3, 2025, 4:16 p.m.