R/ecoli.R

Defines functions missing_ecoli remove_missing_ecoli

# remove_missing_ecoli ---------------------------------------------------------
remove_missing_ecoli <- function(hygiene)
{
  is_missing <- missing_ecoli(hygiene)

  if (! any(is_missing)) {
    return(hygiene)
  }

  kwb.utils::catAndRun(
    sprintf(
      "Removing %d rows where E.coli concentration is missing", sum(is_missing)
    ),
    hygiene[! is_missing, ]
  )
}

# missing_ecoli ----------------------------------------------------------------
missing_ecoli <- function(hygiene)
{
  ecoli <- kwb.utils::selectColumns(hygiene, "e.coli")

  is.na(ecoli) | ecoli == -1
}
KWB-R/fhpredict documentation built on Nov. 1, 2020, 5:58 a.m.