-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_class.Rd
41 lines (36 loc) · 1.71 KB
/
check_class.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{check_class}
\alias{check_class}
\title{Check the class of a function input to a parent function}
\source{
This function is taken from the `utils.add' package (https://github.com/edwardlavender/utils.add). It is defined separately in \code{\link[flapper]{flapper}} to reduce reliance on non-default packages.
}
\usage{
check_class(
arg = deparse(substitute(input)),
input,
if_class = NULL,
to_class,
type = "stop",
coerce_input
)
}
\arguments{
\item{arg}{A character string which defines the argument of the parent function.}
\item{input}{The input to an argument of a parent function.}
\item{if_class}{(optional) A character vector of object class(es). If supplied, the function will only proceed to check the class of the object if the \code{class(input)} is one of \code{if_class}. This is useful if \code{check_class()} is implemented in a loop.}
\item{to_class}{The required class of the input.}
\item{type}{A character which specifies whether to return an error (\code{"stop"}) or a warning ("warning").}
\item{coerce_input}{A function used to coerce \code{input} to the correct object type, if \code{type = "warning"}.}
}
\value{
The function checks the class of the input. If the class is not the same as required by the parent function (i.e., as specified by \code{to_class}), the function returns a helpful error message, or a warning and an object whose class has been coerced to the correct class.
}
\description{
This function checks that the class of an input to a parent function is appropriate. If not, the function either produces a helpful error message or returns a warning.
}
\author{
Edward Lavender
}
\keyword{internal}