R/1.1.checkClusterIdsRequirements.R

Defines functions checkIdsRequirements

checkIdsRequirements <- function(ids) {
  if (dim(ids)[2] > 1) {
    stop("Invalid 'ids' argument. Must be one-dimensional!")
  } else if (typeof(ids$value) == "logical") {
    stop("Invalid 'ids' argument. Shouldn't be logical!")
  } else if (any(is.na(ids$value))) {
    stop("Invalid 'ids' argument. Shouldn't have NA values!")
  } else {
    idsCount <- length(unique(ids %>%
      dplyr::group_by(value) %>%
      dplyr::summarise(count = dplyr::n(), .groups = "drop") %>%
      .$count))
    if (idsCount != 1) {
      stop("Invalid 'ids' argument. Every id should be unique in a wave!")
    }
  }

  return(NULL)
}

Try the Mmcsd package in your browser

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

Mmcsd documentation built on March 31, 2023, 7:23 p.m.