R/is.R

Defines functions is.siglist is.sig

Documented in is.sig is.siglist

#' Is the input a sig?
#' 
#' Does the input inherit from ``sig''?
#' @param x Object to test.
#' @return \code{TRUE} if the object inherits from class ``sig'',
#' and FALSE otherwise.
#' @examples
#' stopifnot(
#'   is.sig(sig(with)),
#'   !is.sig(with)     #functions are not their signatures.
#' )
#' @export
is.sig <- function(x)
{  
  inherits(x, "sig")
}

#' Is the input a siglist?
#' 
#' Does the input inherit from ``siglist''?
#' @param x Object to test.
#' @return \code{TRUE} if the object inherits from class ``siglist'' 
#' and \code{is.sig} returns \code{TRUE} for each element of the input,
#' and FALSE otherwise.
#' @examples
#' stopifnot(
#'   !is.siglist(sig(with))     #1 sig is not a siglist.
#' )
#' @export
is.siglist <- function(x)
{
  inherits(x, "siglist") && 
    all(vapply(x, is.sig, logical(1)))
}

Try the sig package in your browser

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

sig documentation built on April 21, 2022, 5:07 p.m.