R/unknown2NA.R

Defines functions unknown2NA

#' Removing IDs having "UNKNOWN" regardless of case
#'
## Copyright(c) 2017-2024 R. Mark Sharp
## This file is part of nprcgenekeepr
#' Someone started entering "unknown" for unknown parents instead of leaving
#' the field blank in PRIMe.
#' @return A dataframe with "UNKNOWN" values in the columns \code{id},
#' \code{sire}, and \code{dam} replaced with NA
#' @param ped  A dataframe containing at least and "id" field
#' @noRd
unknown2NA <- function(ped) {
  if ("id" %in% names(ped)) {
    ped <- ped[toupper(ped$id) != "UNKNOWN", ]
  }
  if ("sire" %in% names(ped)) {
    ped$sire[toupper(ped$sire) == "UNKNOWN"] <- NA
  }
  if ("dam" %in% names(ped)) {
    ped$dam[toupper(ped$dam) == "UNKNOWN"] <- NA
  }
  ped
}

Try the nprcgenekeepr package in your browser

Any scripts or data that you put into this service are public.

nprcgenekeepr documentation built on June 8, 2025, 10:55 a.m.