R/hides_lgl.R

#' @rdname hides
#' @export
hides_lgl <- function(x, ...){
  UseMethod("hides_lgl")
}

hides_lgl.character <- function(x,na.values=NULL, ...){
  length(setdiff(unique(x),c(NA,na.values))) == 2
}

hides_lgl.factor <- function(x, na.values=NULL, ...){
  length(setdiff(levels(x),c(NA,na.values))) == 2
}

hides_lgl.numeric <- function(x, na.values=NULL, obvious = FALSE, ...){
  length(setdiff(unique(x),c(NA,na.values))) == 2
}

hides_lgl.logical <- function(x, na.values=NULL, obvious = FALSE, ...){
  obvious
}

hides_lgl.default <- function(x, na.values=NULL, ...){
  FALSE
}

hides_lgl.list <- function(x, na.values=NULL, obvious = FALSE, ...){
  sapply(x, hides_lgl, na.values = na.values, obvious = obvious)
}

hides_lgl.data.frame <- function(x, na.values=NULL, obvious = FALSE, ...){
  hides_lgl.list(x, na.values, obvious)
}

hides_lgl.environment <- function(x, na.values=NULL, obvious = FALSE, ...){
  sapply(x, hides_lgl, na.values, obvious)
}
moodymudskipper/hidden documentation built on May 20, 2019, 9:59 a.m.