R/checkFuncs.R

Defines functions allSameLength l1log l1int l1num l1chr

Documented in allSameLength l1chr l1int l1log l1num

#' @name checkFuncs
#' @title Common parameter checks
#' @description Common function parameter checks
#' @param x R object
NULL

#' @describeIn checkFuncs length 1 character
#' @export

l1chr <- function(x) length(x) == 1 && is.character(x)

#' @describeIn checkFuncs length 1 numeric
#' @export

l1num <- function(x) length(x) == 1 && is.numeric(x)

#' @describeIn checkFuncs length 1 integer
#' @export

l1int <- function(x) length(x) == 1 && is.integer(x)

#' @describeIn checkFuncs length 1 logical
#' @export

l1log <- function(x) length(x) == 1 && is.logical(x)

#' @describeIn checkFuncs all same length
#' @export

allSameLength <- function(...) {
  lens <- sapply(list(...), length)
  all(lens == lens[1])
} 
daynefiler/dlfUtils documentation built on Oct. 22, 2021, 9:49 a.m.