-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_names.Rd
38 lines (34 loc) · 1.6 KB
/
check_names.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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{check_names}
\alias{check_names}
\title{Check the names of an object contain required names}
\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_names(
arg = deparse(substitute(input)),
input,
req,
extract_names = names,
type = any
)
}
\arguments{
\item{arg}{A character string which defines the argument of the parent function.}
\item{input}{An object for which the names need to be checked.}
\item{req}{A character vector of required names.}
\item{extract_names}{A function which is used to extract names from \code{input}, such as \code{\link[base]{names}} or \code{\link[base]{colnames}}.}
\item{type}{A function which defines the failure criteria. For example, if \code{type = all}, the function will return an error unless all the names in \code{req} are contained within \code{input}. This is the default. If \code{type = any}, the function will return an error only if none of the names in \code{req} are contained within \code{input}.}
}
\value{
If the input fails the check, the function returns a helpful error message. Otherwise, nothing is returned.
}
\description{
This function checks whether required names are contained within an object. If the object does not contain any/all required names (the precise criteria is controlled by the user), the function returns a helpful error message.
}
\author{
Edward Lavender
}
\keyword{internal}