R/remove_inf.R

Defines functions inf_remove

Documented in inf_remove

#' Title
#'
#' @param df Data frame
#'
#' @importFrom purrr is_empty
#' @return A data frame without Inf values
#' @export
#'

inf_remove <- function(df){
  bad <- which(!is.finite(as.matrix(df)), arr.ind=TRUE)
  bad <- unique(bad[,1])
  bad.plus <- bad+1
  if (length(bad)!=nrow(df) & !purrr::is_empty(bad)){
    df <- df[-bad.plus,]
    df <- df[!rowSums(!is.finite(as.matrix(df))),]
  }
  return(df)
}
roaldarbol/sleepr documentation built on May 9, 2024, 11:30 p.m.