% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/arg_data.R
\name{arg_data}
\alias{arg_data}
\alias{arg_atomic}
\alias{arg_vector}
\alias{arg_list}
\alias{arg_data.frame}
\alias{arg_matrix}
\alias{arg_array}
\alias{arg_env}
\title{Check Common Argument Types}
\usage{
arg_atomic(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_vector(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_list(x, df_ok = FALSE, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_data.frame(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_matrix(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_array(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_data(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_env(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
}
\arguments{
\item{x}{the argument to be checked}

\item{.arg}{the name of the argument supplied to \code{x} to appear in error messages. The default is to extract the argument's name using \code{\link[rlang:caller_arg]{rlang::caller_arg()}}. Ignored if \code{.msg} is supplied.}

\item{.msg}{an optional alternative message to display if an error is thrown instead of the default message.}

\item{.call}{the execution environment of a currently running function, e.g. \code{.call = rlang::current_env()}. The corresponding function call is retrieved and mentioned in error messages as the source of the error. Passed to \code{\link[=err]{err()}}. Set to \code{NULL} to omit call information. The default is to search along the call stack for the first user-facing function in another package, if any.}

\item{df_ok}{\code{logical}; whether to allow data frames (which are technically lists). Default is \code{FALSE} to throw an error on a data frame input.}
}
\value{
Returns \code{NULL} invisibly if an error is not thrown.
}
\description{
Checks whether an argument is an atomic vector (\code{arg_atomic()}), a dimensionless atomic vector (\code{arg_vector()}), a \code{\link{list}} (\code{arg_list()}), a \link[=data.frame]{data frame} (\code{arg_data.frame()}), a \code{\link{matrix}} (\code{arg_matrix()}), an \code{\link{array}} (\code{arg_array()}), a rectangular data set (\code{arg_data()}), or an \code{\link{environment}} (\code{arg_env()}).
}
\details{
Atomic vectors are checked using \code{\link[=is.atomic]{is.atomic()}}. Because matrices are considered atomic vectors, \code{arg_vector()} additionally checks that there is no \code{"dims"} attribute, i.e., that \code{length(dim(x)) == 0L}. \code{arg_data()} checks whether \code{x} is either a data frame or a matrix. \code{arg_list()} checks whether \code{x} is a list; when \code{df = FALSE}, it throws an error when \code{x} is a data frame, even though data frames are lists.
}
\examples{
vec <- 1:6
mat <- as.matrix(vec)
dat <- as.data.frame(mat)
lis <- as.list(vec)
nul <- NULL

# arg_atomic
try(arg_atomic(vec))
try(arg_atomic(mat))
try(arg_atomic(dat))
try(arg_atomic(lis))
try(arg_atomic(nul))

# arg_vector
try(arg_vector(vec))
try(arg_vector(mat))

# arg_matrix
try(arg_matrix(vec))
try(arg_matrix(mat))
try(arg_matrix(dat))

# arg_data.frame
try(arg_data.frame(vec))
try(arg_data.frame(mat))
try(arg_data.frame(dat))

# arg_data
try(arg_data(vec))
try(arg_data(mat))
try(arg_data(dat))
}
\seealso{
\code{\link[=is.atomic]{is.atomic()}}, \code{\link[=is.list]{is.list()}}, \code{\link[=is.data.frame]{is.data.frame()}}, \code{\link[=is.matrix]{is.matrix()}}, \code{\link[=is.array]{is.array()}}, \code{\link[=is.environment]{is.environment()}}, \code{\link[=arg_is]{arg_is()}}
}
