R/clean_NAsInf.R

Defines functions clean_NAsInf

Documented in clean_NAsInf

#' cleans dataframe from NAs and Inf values
#
#' @param df dataframe. df to be cleaned
#
#' @return df dataframe.
#' @importFrom stats na.omit
#' @export

clean_NAsInf <- function(df){
  # eliminate NAs
  df <- stats::na.omit(object = df)
  # eliminate infs
  Infval <- unlist(lapply(data.frame(lapply(df, is.infinite)), which))
  if (length(Infval)>0) df <- df[-Infval,]
  return(df)
}
jbferet/biodivMapR documentation built on April 12, 2025, 1:32 p.m.