R/disallowed_combinations.R

Defines functions disallowed_combinations

Documented in disallowed_combinations

#'@title Detect and list disallowed combinations in candidate set
#'
#'@description Detects and list disallowed combinations in candidate set
#'
#'@param candidateset Block list
#'@keywords internal
#'@return Returns a list of the disallowed combinations

disallowed_combinations = function(candidateset) {

  inputlevels = lapply(candidateset, unique)
  fullcandidateset = expand.grid(inputlevels)
  anydisallowed = nrow(candidateset) != nrow(fullcandidateset)

  if (anydisallowed) {
    combinedcandidatesets = rbind(fullcandidateset, candidateset)
    return(combinedcandidatesets[!duplicated(combinedcandidatesets, fromLast = TRUE) & !duplicated(combinedcandidatesets), ])
  } else {
    return(data.frame())
  }
}

Try the skpr package in your browser

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

skpr documentation built on July 9, 2023, 7:23 p.m.