chk/ 0000755 0001762 0000144 00000000000 14507671602 011027 5 ustar ligges users chk/NAMESPACE 0000644 0001762 0000144 00000006616 14436206156 012256 0 ustar ligges users # Generated by roxygen2: do not edit by hand
export(abort_chk)
export(backtick_chk)
export(cc)
export(check_data)
export(check_dim)
export(check_dirs)
export(check_files)
export(check_key)
export(check_names)
export(check_values)
export(chk_all)
export(chk_all_equal)
export(chk_all_equivalent)
export(chk_all_identical)
export(chk_array)
export(chk_atomic)
export(chk_character)
export(chk_character_or_factor)
export(chk_chr)
export(chk_compatible_lengths)
export(chk_count)
export(chk_data)
export(chk_date)
export(chk_date_time)
export(chk_datetime)
export(chk_dbl)
export(chk_dir)
export(chk_dirs)
export(chk_double)
export(chk_environment)
export(chk_equal)
export(chk_equivalent)
export(chk_ext)
export(chk_factor)
export(chk_false)
export(chk_file)
export(chk_files)
export(chk_flag)
export(chk_function)
export(chk_gt)
export(chk_gte)
export(chk_has)
export(chk_identical)
export(chk_in)
export(chk_integer)
export(chk_is)
export(chk_join)
export(chk_length)
export(chk_lgl)
export(chk_list)
export(chk_logical)
export(chk_lt)
export(chk_lte)
export(chk_match)
export(chk_matrix)
export(chk_missing)
export(chk_named)
export(chk_no_missing)
export(chk_not_any_na)
export(chk_not_empty)
export(chk_not_missing)
export(chk_not_null)
export(chk_not_subset)
export(chk_null)
export(chk_null_or)
export(chk_number)
export(chk_numeric)
export(chk_off)
export(chk_on)
export(chk_orderset)
export(chk_proportion)
export(chk_range)
export(chk_s3_class)
export(chk_s4_class)
export(chk_scalar)
export(chk_setequal)
export(chk_sorted)
export(chk_string)
export(chk_subset)
export(chk_superset)
export(chk_true)
export(chk_tz)
export(chk_unique)
export(chk_unused)
export(chk_used)
export(chk_valid_name)
export(chk_vector)
export(chk_whole_number)
export(chk_whole_numeric)
export(chk_wnum)
export(chkor)
export(chkor_vld)
export(deparse_backtick)
export(deparse_backtick_chk)
export(err)
export(expect_chk_error)
export(is_chk_on)
export(message_chk)
export(msg)
export(p)
export(p0)
export(unbacktick_chk)
export(vld_all)
export(vld_all_equal)
export(vld_all_equivalent)
export(vld_all_identical)
export(vld_array)
export(vld_atomic)
export(vld_character)
export(vld_character_or_factor)
export(vld_chr)
export(vld_compatible_lengths)
export(vld_count)
export(vld_data)
export(vld_date)
export(vld_date_time)
export(vld_datetime)
export(vld_dbl)
export(vld_dir)
export(vld_double)
export(vld_environment)
export(vld_equal)
export(vld_equivalent)
export(vld_ext)
export(vld_factor)
export(vld_false)
export(vld_file)
export(vld_flag)
export(vld_function)
export(vld_gt)
export(vld_gte)
export(vld_identical)
export(vld_integer)
export(vld_is)
export(vld_join)
export(vld_length)
export(vld_lgl)
export(vld_list)
export(vld_logical)
export(vld_lt)
export(vld_lte)
export(vld_match)
export(vld_matrix)
export(vld_missing)
export(vld_named)
export(vld_no_missing)
export(vld_not_any_na)
export(vld_not_empty)
export(vld_not_missing)
export(vld_not_null)
export(vld_not_subset)
export(vld_null)
export(vld_number)
export(vld_numeric)
export(vld_orderset)
export(vld_range)
export(vld_s3_class)
export(vld_s4_class)
export(vld_scalar)
export(vld_setequal)
export(vld_sorted)
export(vld_string)
export(vld_subset)
export(vld_superset)
export(vld_true)
export(vld_tz)
export(vld_unique)
export(vld_unused)
export(vld_used)
export(vld_valid_name)
export(vld_vector)
export(vld_whole_number)
export(vld_whole_numeric)
export(vld_wnum)
export(wrn)
import(lifecycle)
import(rlang)
chk/LICENSE 0000644 0001762 0000144 00000000060 14507605651 012031 0 ustar ligges users YEAR: 2023
COPYRIGHT HOLDER: Poisson Consulting
chk/README.md 0000644 0001762 0000144 00000005630 14506571213 012306 0 ustar ligges users
# chk
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://github.com/poissonconsulting/chk/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/poissonconsulting/chk?branch=master)
[](https://opensource.org/license/mit/)
[](https://cran.r-project.org/package=chk)

`chk` is an R package for developers to check user-supplied function
arguments.
It is designed to be simple, customizable and fast.
## Installation
To install the latest release from [CRAN](https://cran.r-project.org)
``` r
install.packages("chk")
```
To install the latest development version from
[GitHub](https://github.com/poissonconsulting/chk)
``` r
# install.packages("remotes")
remotes::install_github("poissonconsulting/chk")
```
## Demonstration
`chk` provides simple commonly used checks as (`chk_` functions) which
can be combined together for more complex checking.
``` r
library(chk)
y <- "a"
chk_string(y)
chk_flag(y)
#> Error:
#> ! `y` must be a flag (TRUE or FALSE).
data <- data.frame(x = 1:2)
chk_range(nrow(data), c(3, 8))
#> Error:
#> ! `nrow(data)` must be between 3 and 8, not 2.
```
Or used inside functions to test user-provided arguments.
``` r
my_fun <- function(x) {
chk_flag(x)
x
}
my_fun(TRUE)
#> [1] TRUE
my_fun(NA)
#> Error in `my_fun()`:
#> ! `x` must be a flag (TRUE or FALSE).
```
Error messages follow the [tidyverse style
guide](https://style.tidyverse.org/error-messages.html) while the errors
themselves are [rlang
errors](https://rlang.r-lib.org/reference/abort.html) of class
`chk_error`.
## Information
For more information see the [Get
Started](https://poissonconsulting.github.io/chk/articles/chk.html)
vignette.
## Inspiration
- [datacheckr](https://github.com/poissonconsulting/datacheckr/)
- [checkr](https://github.com/poissonconsulting/checkr/)
- [err](https://github.com/poissonconsulting/err/)
- [testthat](https://github.com/r-lib/testthat/)
## Contribution
Please report any
[issues](https://github.com/poissonconsulting/chk/issues).
[Pull requests](https://github.com/poissonconsulting/chk/pulls) are
always welcome.
## Code of Conduct
Please note that the chk project is released with a [Contributor Code of
Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms
chk/man/ 0000755 0001762 0000144 00000000000 14436206156 011601 5 ustar ligges users chk/man/chk_length.Rd 0000644 0001762 0000144 00000002535 14436206156 014203 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-length.R
\name{chk_length}
\alias{chk_length}
\alias{vld_length}
\title{Check Length}
\usage{
chk_length(x, length = 1L, upper = length, x_name = NULL)
vld_length(x, length = 1L, upper = length)
}
\arguments{
\item{x}{The object to check.}
\item{length}{A count of the length.}
\item{upper}{A count of the max length.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks length is a particular value or range using
\code{length(x) >= length && length(x) <= upper}
}
\section{Functions}{
\itemize{
\item \code{vld_length()}: Validate Length
}}
\examples{
# chk_length
chk_length("text")
try(vld_length("text", length = 2))
# vld_length
vld_length(2:1, 2)
vld_length(2:1, 1)
}
\seealso{
\code{\link[=check_dim]{check_dim()}}
Other chk_misc:
\code{\link{chk_match}()},
\code{\link{chk_missing}()},
\code{\link{chk_named}()},
\code{\link{chk_not_any_na}()},
\code{\link{chk_not_empty}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_sorted}()},
\code{\link{chk_unique}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/cc.Rd 0000644 0001762 0000144 00000002035 14436206156 012455 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cc.R
\name{cc}
\alias{cc}
\title{Concatenate with Commas}
\usage{
cc(
x,
conj = ", ",
sep = ", ",
brac = if (is.character(x) || is.factor(x)) "'" else "",
ellipsis = 10L,
chk = TRUE
)
}
\arguments{
\item{x}{The object to concatenate.}
\item{conj}{A string of the conjunction to separate the last value by.}
\item{sep}{A string of the separator.}
\item{brac}{A string to brac the values by.}
\item{ellipsis}{A numeric scalar of the maximum number of values to display
before using an ellipsis.}
\item{chk}{A flag specifying whether to check the other parameters.}
}
\value{
A string.
}
\description{
Concatenates object values into a string with each value separated by a comma
and the last value separated by a conjunction.
}
\details{
By default, if x has more than 10 values an ellipsis is used
to ensure only 10 values are displayed (including the ellipsis).
}
\examples{
cc(1:2)
cc(1:2, conj = " or")
cc(3:1, brac = "'")
cc(1:11)
cc(as.character(1:2))
}
chk/man/chk_unused.Rd 0000644 0001762 0000144 00000001367 14436206156 014227 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-unused.R
\name{chk_unused}
\alias{chk_unused}
\alias{vld_unused}
\title{Check ... Unused}
\usage{
chk_unused(...)
vld_unused(...)
}
\arguments{
\item{...}{Additional arguments.}
}
\value{
The \code{chk_} function throws an informative error if the test fails.
}
\description{
Checks if ... is unused
\code{length(list(...)) == 0L}
}
\section{Functions}{
\itemize{
\item \code{vld_unused()}: Validate ... Unused
}}
\examples{
# chk_unused
fun <- function(x, ...) {
chk_unused(...)
x
}
fun(1)
try(fun(1, 2))
# vld_unused
fun <- function(x, ...) {
vld_unused(...)
}
fun(1)
try(fun(1, 2))
}
\seealso{
Other chk_ellipsis:
\code{\link{chk_used}()}
}
\concept{chk_ellipsis}
chk/man/chk-package.Rd 0000644 0001762 0000144 00000002531 14507622000 014214 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-package.R
\docType{package}
\name{chk-package}
\alias{chk}
\alias{chk-package}
\title{chk: Check User-Supplied Function Arguments}
\description{
\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
For developers to check user-supplied function arguments. It is designed to be simple, fast and customizable. Error messages follow the tidyverse style guide.
}
\seealso{
Useful links:
\itemize{
\item \url{https://poissonconsulting.github.io/chk/}
\item \url{https://github.com/poissonconsulting/chk/}
\item Report bugs at \url{https://github.com/poissonconsulting/chk/issues/}
}
}
\author{
\strong{Maintainer}: Joe Thorley \email{joe@poissonconsulting.ca} (\href{https://orcid.org/0000-0002-7683-4592}{ORCID})
Authors:
\itemize{
\item Kirill Müller (\href{https://orcid.org/0000-0002-1416-3412}{ORCID})
\item Ayla Pearson (\href{https://orcid.org/0000-0001-7388-1222}{ORCID})
}
Other contributors:
\itemize{
\item Nadine Hussein \email{nadine@poissonconsulting.ca} (\href{https://orcid.org/0000-0003-4470-8361}{ORCID}) [contributor]
\item Evan Amies-Galonski \email{evan@poissonconsulting.ca} (\href{https://orcid.org/0000-0003-1096-2089}{ORCID}) [contributor]
\item Poisson Consulting [copyright holder, funder]
}
}
\keyword{internal}
chk/man/chk_atomic.Rd 0000644 0001762 0000144 00000002260 14436206156 014171 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-atomic.R
\name{chk_atomic}
\alias{chk_atomic}
\alias{vld_atomic}
\title{Check Atomic}
\usage{
chk_atomic(x, x_name = NULL)
vld_atomic(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if atomic using
\code{is.atomic(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_atomic()}: Validate Atomic
}}
\examples{
# chk_atomic
chk_atomic(1)
try(chk_atomic(list(1)))
# vld_atomic
vld_atomic(1)
vld_atomic(matrix(1:3))
vld_atomic(character(0))
vld_atomic(list(1))
vld_atomic(NULL)
}
\seealso{
Other chk_is:
\code{\link{chk_array}()},
\code{\link{chk_data}()},
\code{\link{chk_function}()},
\code{\link{chk_is}()},
\code{\link{chk_matrix}()},
\code{\link{chk_numeric}()},
\code{\link{chk_s3_class}()},
\code{\link{chk_s4_class}()},
\code{\link{chk_vector}()},
\code{\link{chk_whole_numeric}()}
}
\concept{chk_is}
chk/man/chk_is.Rd 0000644 0001762 0000144 00000002267 14436206156 013337 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-is.R
\name{chk_is}
\alias{chk_is}
\alias{vld_is}
\title{Check Class}
\usage{
chk_is(x, class, x_name = NULL)
vld_is(x, class)
}
\arguments{
\item{x}{The object to check.}
\item{class}{A string specifying the class.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks inherits from class using
\code{inherits(x, class)}
}
\section{Functions}{
\itemize{
\item \code{vld_is()}: Validate Inherits from Class
}}
\examples{
chk_is(1, "numeric")
try(chk_is(1L, "double"))
# vld_is
vld_is(numeric(0), "numeric")
vld_is(1L, "double")
}
\seealso{
Other chk_is:
\code{\link{chk_array}()},
\code{\link{chk_atomic}()},
\code{\link{chk_data}()},
\code{\link{chk_function}()},
\code{\link{chk_matrix}()},
\code{\link{chk_numeric}()},
\code{\link{chk_s3_class}()},
\code{\link{chk_s4_class}()},
\code{\link{chk_vector}()},
\code{\link{chk_whole_numeric}()}
}
\concept{chk_is}
chk/man/chkor.Rd 0000644 0001762 0000144 00000001334 14436206156 013177 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chkor.R
\name{chkor}
\alias{chkor}
\title{Check OR}
\usage{
chkor(...)
}
\arguments{
\item{...}{Multiple \code{chk_} functions.}
}
\value{
An informative error if the test fails.
}
\description{
The \code{chkor()} function has been deprecated for the faster \code{chkor_vld()}.
}
\details{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}
\examples{
chkor()
chkor(chk_flag(TRUE))
try(chkor(chk_flag(1)))
try(chkor(chk_flag(1), chk_flag(2)))
chkor(chk_flag(1), chk_flag(TRUE))
}
\seealso{
\code{\link[=chk_null_or]{chk_null_or()}}
}
chk/man/expect_chk_error.Rd 0000644 0001762 0000144 00000007535 14436206156 015430 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/expect-chk-error.R
\name{expect_chk_error}
\alias{expect_chk_error}
\title{Expect Chk Error}
\usage{
expect_chk_error(
object,
regexp = NULL,
...,
info = NULL,
label = NULL,
class = NULL
)
}
\arguments{
\item{object}{Object to test.
Supports limited unquoting to make it easier to generate readable failures
within a function or for loop. See \link[testthat]{quasi_label} for more details.}
\item{regexp}{Regular expression to test against.
\itemize{
\item A character vector giving a regular expression that must match the
error message.
\item If \code{NULL}, the default, asserts that there should be an error,
but doesn't test for a specific value.
\item If \code{NA}, asserts that there should be no errors, but we now recommend
using \code{\link[testthat:expect_no_error]{expect_no_error()}} and friends instead.
}
Note that you should only use \code{message} with errors/warnings/messages
that you generate. Avoid tests that rely on the specific text generated by
another package since this can easily change. If you do need to test text
generated by another package, either protect the test with \code{skip_on_cran()}
or use \code{expect_snapshot()}.}
\item{...}{
Arguments passed on to \code{\link[testthat:expect_match]{expect_match}}
\describe{
\item{\code{fixed}}{If \code{TRUE}, treats \code{regexp} as a string to be matched exactly
(not a regular expressions). Overrides \code{perl}.}
\item{\code{perl}}{logical. Should Perl-compatible regexps be used?}
}}
\item{info}{Extra information to be included in the message. This argument
is soft-deprecated and should not be used in new code. Instead see
alternatives in \link[testthat]{quasi_label}.}
\item{label}{Used to customise failure messages. For expert use only.}
\item{class}{Must be NULL.}
}
\value{
If \code{regexp = NA}, the value of the first argument; otherwise
the captured condition.
}
\description{
\code{\link[=expect_chk_error]{expect_chk_error()}} checks that code throws an error
of class \code{"chk_error"} with a message that matches regexp.
See below for more details.
}
\section{Testing \code{message} vs \code{class}}{
When checking that code generates an error, it's important to check that the
error is the one you expect. There are two ways to do this. The first
way is the simplest: you just provide a \code{regexp} that match some fragment
of the error message. This is easy, but fragile, because the test will
fail if the error message changes (even if its the same error).
A more robust way is to test for the class of the error, if it has one.
You can learn more about custom conditions at
\url{https://adv-r.hadley.nz/conditions.html#custom-conditions}, but in
short, errors are S3 classes and you can generate a custom class and check
for it using \code{class} instead of \code{regexp}.
If you are using \code{expect_error()} to check that an error message is
formatted in such a way that it makes sense to a human, we recommend
using \code{\link[testthat:expect_snapshot]{expect_snapshot()}} instead.
}
\examples{
expect_chk_error(chk_true(FALSE))
try(expect_chk_error(chk_false(FALSE)))
}
\seealso{
\code{\link[testthat:expect_no_error]{expect_no_error()}}, \code{expect_no_warning()},
\code{expect_no_message()}, and \code{expect_no_condition()} to assert
that code runs without errors/warnings/messages/conditions.
Other expectations:
\code{\link[testthat]{comparison-expectations}},
\code{\link[testthat]{equality-expectations}},
\code{\link[testthat]{expect_length}()},
\code{\link[testthat]{expect_match}()},
\code{\link[testthat]{expect_named}()},
\code{\link[testthat]{expect_null}()},
\code{\link[testthat]{expect_output}()},
\code{\link[testthat]{expect_reference}()},
\code{\link[testthat]{expect_silent}()},
\code{\link[testthat]{inheritance-expectations}},
\code{\link[testthat]{logical-expectations}}
}
chk/man/chk_range.Rd 0000644 0001762 0000144 00000002641 14436206156 014014 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-range.R
\name{chk_range}
\alias{chk_range}
\alias{vld_range}
\title{Checks range of non-missing values}
\usage{
chk_range(x, range = c(0, 1), inclusive = TRUE, x_name = NULL)
vld_range(x, range = c(0, 1), inclusive = TRUE)
}
\arguments{
\item{x}{The object to check.}
\item{range}{A non-missing sorted vector of length 2 of the lower and
upper permitted values.}
\item{inclusive}{A flag specifying whether the range is exclusive.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks all non-missing values fall within range using
If inclusive
\code{all(x[!is.na(x)] >= range[1] & x[!is.na(x)] <= range[2])}
else
\code{all(x[!is.na(x)] > range[1] & x[!is.na(x)] < range[2])}
}
\section{Functions}{
\itemize{
\item \code{vld_range()}: Validate Range
}}
\examples{
# chk_range
chk_range(0)
try(chk_range(-0.1))
# vld_range
vld_range(numeric(0))
vld_range(0)
vld_range(-0.1)
vld_range(c(0.1, 0.2, NA))
vld_range(c(0.1, 0.2, NA), range = c(0, 1))
}
\seealso{
Other chk_ranges:
\code{\link{chk_gte}()},
\code{\link{chk_gt}()},
\code{\link{chk_lte}()},
\code{\link{chk_lt}()}
}
\concept{chk_ranges}
chk/man/chk_string.Rd 0000644 0001762 0000144 00000002132 14436206156 014221 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-string.R
\name{chk_string}
\alias{chk_string}
\alias{vld_string}
\title{Check String}
\usage{
chk_string(x, x_name = NULL)
vld_string(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if string
\code{is.character(x) && length(x) == 1L && !anyNA(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_string()}: Validate String
}}
\examples{
# chk_string
chk_string("1")
try(chk_string(1))
# vld_string
vld_string("1")
vld_string("")
vld_string(1)
vld_string(NA_character_)
vld_string(c("1", "1"))
}
\seealso{
Other chk_scalars:
\code{\link{chk_date_time}()},
\code{\link{chk_date}()},
\code{\link{chk_number}()},
\code{\link{chk_scalar}()},
\code{\link{chk_tz}()},
\code{\link{chk_whole_number}()}
}
\concept{chk_scalars}
chk/man/chk_superset.Rd 0000644 0001762 0000144 00000002212 14436206156 014564 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-superset.R
\name{chk_superset}
\alias{chk_superset}
\alias{vld_superset}
\title{Check Superset}
\usage{
chk_superset(x, values, x_name = NULL)
vld_superset(x, values)
}
\arguments{
\item{x}{The object to check.}
\item{values}{A vector of the permitted values.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if includes all values using
\code{all(values \%in\% x)}
}
\section{Functions}{
\itemize{
\item \code{vld_superset()}: Validates Superset
}}
\examples{
# chk_superset
chk_superset(1:3, 1)
try(chk_superset(1:3, 4))
# vld_superset
vld_superset(1:3, 1)
vld_superset(1:3, 4)
vld_superset(integer(0), integer(0))
}
\seealso{
Other chk_set:
\code{\link{chk_join}()},
\code{\link{chk_not_subset}()},
\code{\link{chk_orderset}()},
\code{\link{vld_not_subset}()},
\code{\link{vld_orderset}()}
}
\concept{chk_set}
chk/man/chk_whole_numeric.Rd 0000644 0001762 0000144 00000002611 14436206156 015555 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-whole-numeric.R
\name{chk_whole_numeric}
\alias{chk_whole_numeric}
\alias{vld_whole_numeric}
\title{Check Whole Numeric}
\usage{
chk_whole_numeric(x, x_name = NULL)
vld_whole_numeric(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if integer vector or double equivalent using
\code{is.integer(x) || (is.double(x) && vld_true(all.equal(x, as.integer(x))))}
}
\section{Functions}{
\itemize{
\item \code{vld_whole_numeric()}: Validate Whole Numeric
}}
\examples{
# chk_whole_numeric
chk_whole_numeric(1)
try(chk_whole_numeric(1.1))
# vld_whole_numeric
vld_whole_numeric(1)
vld_whole_numeric(NA_real_)
vld_whole_numeric(1:2)
vld_whole_numeric(double(0))
vld_whole_numeric(TRUE)
vld_whole_numeric(1.5)
}
\seealso{
Other chk_is:
\code{\link{chk_array}()},
\code{\link{chk_atomic}()},
\code{\link{chk_data}()},
\code{\link{chk_function}()},
\code{\link{chk_is}()},
\code{\link{chk_matrix}()},
\code{\link{chk_numeric}()},
\code{\link{chk_s3_class}()},
\code{\link{chk_s4_class}()},
\code{\link{chk_vector}()}
}
\concept{chk_is}
chk/man/chk_whole_number.Rd 0000644 0001762 0000144 00000002444 14436206156 015407 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-whole-number.R
\name{chk_whole_number}
\alias{chk_whole_number}
\alias{vld_whole_number}
\title{Check Whole Number}
\usage{
chk_whole_number(x, x_name = NULL)
vld_whole_number(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if non-missing integer scalar or double equivalent using
\code{vld_number(x) && (is.integer(x) || vld_true(all.equal(x, trunc(x))))}
\strong{Pass}: \code{1}, \code{2L}, \code{1e10}, \code{-Inf}
\strong{Fail}: \code{"a"}, \code{1:3}, \code{NA_integer_}, \code{log(10)}
}
\section{Functions}{
\itemize{
\item \code{vld_whole_number()}: Validate Whole Number
}}
\examples{
# chk_whole_number
chk_whole_number(2)
try(chk_whole_number(1.1))
# vld_whole_number
vld_whole_number(2)
}
\seealso{
Other chk_scalars:
\code{\link{chk_date_time}()},
\code{\link{chk_date}()},
\code{\link{chk_number}()},
\code{\link{chk_scalar}()},
\code{\link{chk_string}()},
\code{\link{chk_tz}()}
}
\concept{chk_scalars}
chk/man/abort_chk.Rd 0000644 0001762 0000144 00000003237 14436206156 014031 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{abort_chk}
\alias{abort_chk}
\title{Abort Check}
\usage{
abort_chk(..., n = NULL, tidy = TRUE, call = rlang::caller_call(2))
}
\arguments{
\item{...}{Multiple objects that are converted to a string using
\code{paste0(..., collapse = '')}.}
\item{n}{The value of n for converting \code{sprintf}-like types.}
\item{tidy}{A flag specifying whether capitalize the first character and add a missing period.}
\item{call}{The execution environment of a currently running
function, e.g. \code{call = caller_env()}. The corresponding function
call is retrieved and mentioned in error messages as the source
of the error.
You only need to supply \code{call} when throwing a condition from a
helper function which wouldn't be relevant to mention in the
message.
Can also be \code{NULL} or a \link[rlang:topic-defuse]{defused function call} to
respectively not display any call or hard-code a code to display.
For more information about error calls, see \ifelse{html}{\link[rlang:topic-error-call]{Including function calls in error messages}}{\link[rlang:topic-error-call]{Including function calls in error messages}}.}
}
\value{
Throws an error of class \code{'chk_error'}.
}
\description{
A wrapper on \code{\link[=err]{err()}} that sets the subclass to be \code{'chk_error'}.
}
\details{
It is exported to allow users to easily construct their own \code{chk_} functions.
}
\examples{
try(abort_chk("x must be NULL"))
try(abort_chk("`x` must be NULL"))
try(abort_chk("there \%r \%n problem value\%s", n = 1))
try(abort_chk("there \%r \%n problem value\%s", n = 1.5))
}
\seealso{
\code{\link[=err]{err()}}
}
chk/man/chk_dbl.Rd 0000644 0001762 0000144 00000002442 14436206156 013460 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-dbl.R
\name{chk_dbl}
\alias{chk_dbl}
\alias{vld_dbl}
\title{Check Double Scalar}
\usage{
chk_dbl(x, x_name = NULL)
vld_dbl(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if double scalar using
\code{is.double(x) && length(x) == 1L}
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}
\section{Functions}{
\itemize{
\item \code{vld_dbl()}: Validate Double
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}}
\examples{
# chk_dbl
chk_dbl(1)
try(chk_dbl(1L))
# vld_dbl
vld_dbl(1)
vld_dbl(double(0))
vld_dbl(NA_real_)
vld_dbl(c(1, 1))
vld_dbl(1L)
}
\seealso{
Other deprecated:
\code{\link{chk_chr}()},
\code{\link{chk_deprecated}},
\code{\link{chk_wnum}()}
}
\concept{deprecated}
chk/man/chk_null.Rd 0000644 0001762 0000144 00000001513 14436206156 013667 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-null.R
\name{chk_null}
\alias{chk_null}
\alias{vld_null}
\title{Check NULL}
\usage{
chk_null(x, x_name = NULL)
vld_null(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if NULL using
\code{is.null(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_null()}: Validate NULL
}}
\examples{
# chk_null
try(chk_null(1))
chk_null(NULL)
# vld_null
vld_null(NULL)
vld_null(1)
}
\seealso{
Other chk_nulls:
\code{\link{chk_not_null}()}
}
\concept{chk_nulls}
chk/man/chk_named.Rd 0000644 0001762 0000144 00000002275 14436206156 014007 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-named.R
\name{chk_named}
\alias{chk_named}
\alias{vld_named}
\title{Check Named}
\usage{
chk_named(x, x_name = NULL)
vld_named(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is named using
\code{!is.null(names(x))}
}
\section{Functions}{
\itemize{
\item \code{vld_named()}: Validate Named
}}
\examples{
# chk_named
chk_named(c(x = 1))
try(chk_named(list(1)))
# vld_named
vld_named(c(x = 1))
vld_named(list(x = 1))
vld_named(c(x = 1)[-1])
vld_named(list(x = 1)[-1])
vld_named(1)
vld_named(list(1))
}
\seealso{
Other chk_misc:
\code{\link{chk_length}()},
\code{\link{chk_match}()},
\code{\link{chk_missing}()},
\code{\link{chk_not_any_na}()},
\code{\link{chk_not_empty}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_sorted}()},
\code{\link{chk_unique}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/chkor_vld.Rd 0000644 0001762 0000144 00000001426 14436206156 014046 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chkor-vld.R
\name{chkor_vld}
\alias{chkor_vld}
\title{Chk OR}
\usage{
chkor_vld(...)
}
\arguments{
\item{...}{Multiple \code{vld_} calls.
A common mistake is to pass \code{chk_} calls.
\code{chkor_vld()} is relatively slow.
If at all possible use \code{\link[=chk_null_or]{chk_null_or()}} or first test using the individual
\code{vld_} functions and then call \code{chkor_vld()} to generate an informative
error message.}
}
\value{
An informative error if the test fails.
}
\description{
Chk OR
}
\examples{
chkor_vld()
chkor_vld(vld_flag(TRUE))
try(chkor_vld(vld_flag(1)))
try(chkor_vld(vld_flag(1), vld_flag(2)))
chkor_vld(vld_flag(1), vld_flag(TRUE))
}
\seealso{
\code{\link[=chk_null_or]{chk_null_or()}}
}
chk/man/check_key.Rd 0000644 0001762 0000144 00000001635 14436206156 014022 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check-key.R
\name{check_key}
\alias{check_key}
\title{Check Key}
\usage{
check_key(x, key = character(0), na_distinct = FALSE, x_name = NULL)
}
\arguments{
\item{x}{The object to check.}
\item{key}{A character vector of the columns that represent a unique key.}
\item{na_distinct}{A flag specifying whether missing values should be considered distinct.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
An informative error if the test fails or an invisible copy of x.
}
\description{
Checks if columns have unique rows.
}
\examples{
x <- data.frame(x = c(1, 2), y = c(1, 1))
check_key(x)
try(check_key(x, "y"))
}
\seealso{
Other check:
\code{\link{check_data}()},
\code{\link{check_dim}()},
\code{\link{check_dirs}()},
\code{\link{check_files}()},
\code{\link{check_names}()},
\code{\link{check_values}()}
}
\concept{check}
chk/man/chk_lte.Rd 0000644 0001762 0000144 00000002200 14436206156 013473 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-lte.R
\name{chk_lte}
\alias{chk_lte}
\alias{vld_lte}
\title{Check Less Than or Equal To}
\usage{
chk_lte(x, value = 0, x_name = NULL)
vld_lte(x, value = 0)
}
\arguments{
\item{x}{The object to check.}
\item{value}{A non-missing scalar of a value.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if all non-missing values are less than or equal to y using
\code{all(x[!is.na(x)] <= value)}
}
\section{Functions}{
\itemize{
\item \code{vld_lte()}: Validate Less Than or Equal To
}}
\examples{
# chk_lte
chk_lte(0)
try(chk_lte(0.1))
# vld_lte
vld_lte(numeric(0))
vld_lte(0)
vld_lte(0.1)
vld_lte(c(-0.1, -0.2, NA))
vld_lte(c(-0.1, -0.2, NA), value = -1)
}
\seealso{
Other chk_ranges:
\code{\link{chk_gte}()},
\code{\link{chk_gt}()},
\code{\link{chk_lt}()},
\code{\link{chk_range}()}
}
\concept{chk_ranges}
chk/man/chk_equivalent.Rd 0000644 0001762 0000144 00000002407 14436206156 015075 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-equivalent.R
\name{chk_equivalent}
\alias{chk_equivalent}
\alias{vld_equivalent}
\title{Check Equivalent}
\usage{
chk_equivalent(x, y, tolerance = sqrt(.Machine$double.eps), x_name = NULL)
vld_equivalent(x, y, tolerance = sqrt(.Machine$double.eps))
}
\arguments{
\item{x}{The object to check.}
\item{y}{An object to check against.}
\item{tolerance}{A non-negative numeric scalar.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is equivalent (equal ignoring attributes) to y using
\code{vld_true(all.equal(x, y, tolerance, check.attributes = FALSE))}
}
\section{Functions}{
\itemize{
\item \code{vld_equivalent()}: Validate Equivalent
}}
\examples{
# chk_equivalent
chk_equivalent(1, 1.00000001)
try(chk_equivalent(1, 1.0000001))
chk_equivalent(1, 1L)
chk_equivalent(c(x = 1), c(y = 1))
vld_equivalent(c(x = 1), c(y = 1L))
}
\seealso{
Other chk_equals:
\code{\link{chk_equal}()},
\code{\link{chk_identical}()}
}
\concept{chk_equals}
chk/man/chk_function.Rd 0000644 0001762 0000144 00000002522 14436206156 014543 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-function.R
\name{chk_function}
\alias{chk_function}
\alias{vld_function}
\title{Check Function}
\usage{
chk_function(x, formals = NULL, x_name = NULL)
vld_function(x, formals = NULL)
}
\arguments{
\item{x}{The object to check.}
\item{formals}{A count of the number of formal arguments.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is a function using
\code{is.function(x) && (is.null(formals) || length(formals(x)) == formals)}
}
\section{Functions}{
\itemize{
\item \code{vld_function()}: Validate Function
}}
\examples{
# chk_function
chk_function(mean)
try(chk_function(1))
# vld_function
vld_function(mean)
vld_function(function(x) x)
vld_function(1)
vld_function(list(1))
}
\seealso{
Other chk_is:
\code{\link{chk_array}()},
\code{\link{chk_atomic}()},
\code{\link{chk_data}()},
\code{\link{chk_is}()},
\code{\link{chk_matrix}()},
\code{\link{chk_numeric}()},
\code{\link{chk_s3_class}()},
\code{\link{chk_s4_class}()},
\code{\link{chk_vector}()},
\code{\link{chk_whole_numeric}()}
}
\concept{chk_is}
chk/man/chk_subset.Rd 0000644 0001762 0000144 00000002511 14436206156 014221 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-not-subset.R, R/chk-subset.R
\name{vld_not_subset}
\alias{vld_not_subset}
\alias{chk_subset}
\alias{vld_subset}
\title{Check Subset}
\usage{
vld_not_subset(x, values)
chk_subset(x, values, x_name = NULL)
vld_subset(x, values)
}
\arguments{
\item{x}{The object to check.}
\item{values}{A vector of the permitted values.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if all values in values using
\code{all(x \%in\% values)}
}
\section{Functions}{
\itemize{
\item \code{vld_not_subset()}: Validate Not Subset
\item \code{vld_subset()}: Validate Subset
}}
\examples{
# vld_not_subset
vld_not_subset(numeric(0), 1:10)
vld_not_subset(1, 1:10)
vld_not_subset(11, 1:10)
# chk_subset
chk_subset(1, 1:10)
try(chk_subset(11, 1:10))
# vld_subset
vld_subset(numeric(0), 1:10)
vld_subset(1, 1:10)
vld_subset(11, 1:10)
}
\seealso{
Other chk_set:
\code{\link{chk_join}()},
\code{\link{chk_not_subset}()},
\code{\link{chk_orderset}()},
\code{\link{chk_superset}()},
\code{\link{vld_orderset}()}
}
\concept{chk_set}
chk/man/chk_orderset.Rd 0000644 0001762 0000144 00000002001 14436206156 014535 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-orderset.R
\name{chk_orderset}
\alias{chk_orderset}
\title{Check Set Ordered}
\usage{
chk_orderset(x, values, x_name = NULL)
}
\arguments{
\item{x}{The object to check.}
\item{values}{A vector of the permitted values.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if the first occurrence of each shared element
in x is equivalent to the first occurrence of each shared element in values using
\code{vld_equivalent(unique(x[x \%in\% values]), values[values \%in\% x])}.
}
\examples{
# chk_orderset
chk_orderset(1:2, 1:2)
try(chk_orderset(2:1, 1:2))
}
\seealso{
Other chk_set:
\code{\link{chk_join}()},
\code{\link{chk_not_subset}()},
\code{\link{chk_superset}()},
\code{\link{vld_not_subset}()},
\code{\link{vld_orderset}()}
}
\concept{chk_set}
chk/man/chk_array.Rd 0000644 0001762 0000144 00000002157 14436206156 014040 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-array.R
\name{chk_array}
\alias{chk_array}
\alias{vld_array}
\title{Check Array}
\usage{
chk_array(x, x_name = NULL)
vld_array(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is an array using
\code{is.array(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_array()}: Validate Array
}}
\examples{
# chk_array
chk_array(array(1))
try(chk_array(matrix(1)))
# vld_array
vld_array(1)
vld_array(array(1))
}
\seealso{
Other chk_is:
\code{\link{chk_atomic}()},
\code{\link{chk_data}()},
\code{\link{chk_function}()},
\code{\link{chk_is}()},
\code{\link{chk_matrix}()},
\code{\link{chk_numeric}()},
\code{\link{chk_s3_class}()},
\code{\link{chk_s4_class}()},
\code{\link{chk_vector}()},
\code{\link{chk_whole_numeric}()}
}
\concept{chk_is}
chk/man/chk_matrix.Rd 0000644 0001762 0000144 00000002176 14436206156 014227 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-matrix.R
\name{chk_matrix}
\alias{chk_matrix}
\alias{vld_matrix}
\title{Check Matrix}
\usage{
chk_matrix(x, x_name = NULL)
vld_matrix(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is a matrix using
\code{is.matrix(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_matrix()}: Validate Matrix
}}
\examples{
# chk_matrix
chk_matrix(matrix(1))
try(chk_matrix(array(1)))
# vld_matrix
vld_matrix(1)
vld_matrix(matrix(1))
}
\seealso{
Other chk_is:
\code{\link{chk_array}()},
\code{\link{chk_atomic}()},
\code{\link{chk_data}()},
\code{\link{chk_function}()},
\code{\link{chk_is}()},
\code{\link{chk_numeric}()},
\code{\link{chk_s3_class}()},
\code{\link{chk_s4_class}()},
\code{\link{chk_vector}()},
\code{\link{chk_whole_numeric}()}
}
\concept{chk_is}
chk/man/chk_file.Rd 0000644 0001762 0000144 00000001617 14436206156 013641 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-file.R
\name{chk_file}
\alias{chk_file}
\alias{vld_file}
\title{Check File Exists}
\usage{
chk_file(x, x_name = NULL)
vld_file(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if file exists using
\code{vld_string(x) && file.exists(x) && !dir.exists(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_file()}: Validate File Exists
}}
\examples{
# chk_file
try(chk_file(tempfile()))
# vld_file
vld_file(tempfile())
}
\seealso{
Other chk_files:
\code{\link{chk_dir}()},
\code{\link{chk_ext}()}
}
\concept{chk_files}
chk/man/params.Rd 0000644 0001762 0000144 00000004117 14436206156 013356 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/template.R
\name{params}
\alias{params}
\title{Parameters for chk functions}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
\item{y}{An object to check against.}
\item{chk}{A flag specifying whether to check the other parameters.}
\item{chk_fun}{A chk_ function.}
\item{tolerance}{A non-negative numeric scalar.}
\item{ext}{A character vector of the permitted file extensions
(without the .).}
\item{exists}{A flag specifying whether the files/directories must (or must not) exist.}
\item{value}{A non-missing scalar of a value.}
\item{range}{A non-missing sorted vector of length 2 of the lower and
upper permitted values.}
\item{inclusive}{A flag specifying whether the range is exclusive.}
\item{regexp}{A string of a regular expression.}
\item{values}{A vector of the permitted values.}
\item{class}{A string specifying the class.}
\item{length}{A count of the length.}
\item{upper}{A count of the max length.}
\item{formals}{A count of the number of formal arguments.}
\item{incomparables}{A vector of values that cannot be compared.
FALSE means that all values can be compared.}
\item{by}{A character vector specifying the column names to join x and y on.
If named the names are the corresponding columns in x.}
\item{exclusive}{A flag specifying whether x must only include columns named in values.}
\item{order}{A flag specifying whether the order of columns in x must match names in values.}
\item{nrow}{A flag or a whole numeric vector of the value, value range or possible values.}
\item{key}{A character vector of the columns that represent a unique key.}
\item{vld_fun}{A vld_ function.}
\item{...}{Additional arguments.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Descriptions of the parameters and return values for the chk functions
}
\keyword{internal}
chk/man/chk_missing.Rd 0000644 0001762 0000144 00000002407 14436206156 014371 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-missing.R
\name{chk_missing}
\alias{chk_missing}
\alias{vld_missing}
\title{Check Missing Argument}
\usage{
chk_missing(x, x_name = NULL)
vld_missing(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks argument missing using
\code{missing(x)}
}
\details{
Currently only checks if value is available
(as opposed to whether it was specified).
}
\section{Functions}{
\itemize{
\item \code{vld_missing()}: Validate Missing Argument
}}
\examples{
# chk_missing
fun <- function(x) {
chk_missing(x)
}
fun()
try(fun(1))
# vld_missing
fun <- function(x) {
vld_missing(x)
}
fun()
fun(1)
}
\seealso{
Other chk_misc:
\code{\link{chk_length}()},
\code{\link{chk_match}()},
\code{\link{chk_named}()},
\code{\link{chk_not_any_na}()},
\code{\link{chk_not_empty}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_sorted}()},
\code{\link{chk_unique}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/chk_all_equivalent.Rd 0000644 0001762 0000144 00000002551 14436206156 015725 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-all-equivalent.R
\name{chk_all_equivalent}
\alias{chk_all_equivalent}
\alias{vld_all_equivalent}
\title{Check All Equivalent}
\usage{
chk_all_equivalent(x, tolerance = sqrt(.Machine$double.eps), x_name = NULL)
vld_all_equivalent(x, tolerance = sqrt(.Machine$double.eps))
}
\arguments{
\item{x}{The object to check.}
\item{tolerance}{A non-negative numeric scalar.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks all elements in x equivalent using
\code{length(x) < 2L || all(vapply(x, vld_equivalent, TRUE, y = x[[1]], tolerance = tolerance))}
}
\section{Functions}{
\itemize{
\item \code{vld_all_equivalent()}: Validate All Equivalent
}}
\examples{
# chk_all_equivalent
chk_all_equivalent(c(1, 1.00000001))
try(chk_all_equivalent(c(1, 1.0000001)))
chk_all_equivalent(list(c(x = 1), c(x = 1)))
chk_all_equivalent(list(c(x = 1), c(y = 1)))
# vld_all_equivalent
vld_all_equivalent(c(x = 1, y = 1))
}
\seealso{
Other chk_alls:
\code{\link{chk_all_equal}()},
\code{\link{chk_all_identical}()},
\code{\link{chk_all}()}
}
\concept{chk_alls}
chk/man/chk_gte.Rd 0000644 0001762 0000144 00000002206 14436206156 013474 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-gte.R
\name{chk_gte}
\alias{chk_gte}
\alias{vld_gte}
\title{Check Greater Than or Equal To}
\usage{
chk_gte(x, value = 0, x_name = NULL)
vld_gte(x, value = 0)
}
\arguments{
\item{x}{The object to check.}
\item{value}{A non-missing scalar of a value.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if all non-missing values are greater than or equal to y using
\code{all(x[!is.na(x)] >= value)}
}
\section{Functions}{
\itemize{
\item \code{vld_gte()}: Validate Greater Than or Equal To
}}
\examples{
# chk_gte
chk_gte(0)
try(chk_gte(-0.1))
# vld_gte
vld_gte(numeric(0))
vld_gte(0)
vld_gte(-0.1)
vld_gte(c(0.1, 0.2, NA))
vld_gte(c(0.1, 0.2, NA), value = 1)
}
\seealso{
Other chk_ranges:
\code{\link{chk_gt}()},
\code{\link{chk_lte}()},
\code{\link{chk_lt}()},
\code{\link{chk_range}()}
}
\concept{chk_ranges}
chk/man/chk_dir.Rd 0000644 0001762 0000144 00000001662 14436206156 013500 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-dir.R
\name{chk_dir}
\alias{chk_dir}
\alias{vld_dir}
\title{Check Directory Exists}
\usage{
chk_dir(x, x_name = NULL)
vld_dir(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if directory exists using
\code{vld_string(x) && dir.exists(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_dir()}: Validate Directory Exists
}}
\examples{
# chk_dir
chk_dir(tempdir())
try(chk_dir(tempfile()))
# vld_dir
vld_dir(1)
vld_dir(tempdir())
vld_dir(tempfile())
}
\seealso{
Other chk_files:
\code{\link{chk_ext}()},
\code{\link{chk_file}()}
}
\concept{chk_files}
chk/man/p.Rd 0000644 0001762 0000144 00000001466 14436206156 012336 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/p.R
\name{p}
\alias{p}
\alias{p0}
\title{Concatenate Strings}
\usage{
p(..., sep = " ", collapse = NULL)
p0(..., collapse = NULL)
}
\arguments{
\item{...}{one or more \R objects, to be converted to character vectors.}
\item{sep}{a character string to separate the terms. Not
\code{\link[base]{NA_character_}}.}
\item{collapse}{an optional character string to separate the results. Not
\code{\link[base]{NA_character_}}.}
}
\value{
A character vector.
}
\description{
A wrapper on \code{\link[base:paste]{base::paste()}}.
}
\section{Functions}{
\itemize{
\item \code{p0()}: A wrapper on \code{\link[base:paste]{base::paste0()}}
}}
\examples{
p("a", "b")
p(c("a", "b"), collapse = " ")
p0("a", "b")
p0(c("a", "b"), collapse = "")
}
chk/man/chk_compatible_lengths.Rd 0000644 0001762 0000144 00000003370 14436206156 016563 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-compatible-lengths.R
\name{chk_compatible_lengths}
\alias{chk_compatible_lengths}
\alias{vld_compatible_lengths}
\title{Check Compatible Lengths}
\usage{
chk_compatible_lengths(..., x_name = NULL)
vld_compatible_lengths(...)
}
\arguments{
\item{...}{The objects to check for compatible lengths.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails.
}
\description{
Checks objects (including vectors) have lengths that could be 'strictly
recycled'. That is to say they must all be either zero length or the same
length with some of length 1.
}
\details{
This function helps to check vectors could be 'strictly recycled.'
For example the function will error if you had a vector of length 2 and
length 4, even though the vector of length 2 could be 'loosely recycled' to
match up to the vector of length 4 when combined.
The intent of the function is to check that only strict recycling is
occurring.
}
\section{Functions}{
\itemize{
\item \code{vld_compatible_lengths()}: Validate Compatible Lengths
}}
\examples{
# chk_compatible_lengths
a <- integer(0)
b <- numeric(0)
chk_compatible_lengths(a, b)
a <- 1
b <- 2
chk_compatible_lengths(a, b)
a <- 1:3
b <- 1:3
chk_compatible_lengths(a, b)
b <- 1
chk_compatible_lengths(a, b)
b <- 1:2
try(chk_compatible_lengths(a, b))
b <- 1:6
try(chk_compatible_lengths(a, b))
# vld_compatible_lengths
a <- integer(0)
b <- numeric(0)
vld_compatible_lengths(a, b)
a <- 1
b <- 2
vld_compatible_lengths(a, b)
a <- 1:3
b <- 1:3
vld_compatible_lengths(a, b)
b <- 1
vld_compatible_lengths(a, b)
b <- 1:2
vld_compatible_lengths(a, b)
b <- 1:6
vld_compatible_lengths(a, b)
}
chk/man/chk_all.Rd 0000644 0001762 0000144 00000002137 14436206156 013470 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-all.R
\name{chk_all}
\alias{chk_all}
\alias{vld_all}
\title{Check All}
\usage{
chk_all(x, chk_fun, ..., x_name = NULL)
vld_all(x, vld_fun, ...)
}
\arguments{
\item{x}{The object to check.}
\item{chk_fun}{A chk_ function.}
\item{...}{Additional arguments.}
\item{x_name}{A string of the name of object x or NULL.}
\item{vld_fun}{A vld_ function.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks all elements using
\code{all(vapply(x, chk_fun, TRUE, ...))}
}
\section{Functions}{
\itemize{
\item \code{vld_all()}: Validate All
}}
\examples{
# chk_all
chk_all(TRUE, chk_lgl)
# FIXME try(chk_all(1, chk_lgl))
chk_all(c(TRUE, NA), chk_lgl)
# vld_all
vld_all(c(TRUE, NA), vld_lgl)
}
\seealso{
Other chk_alls:
\code{\link{chk_all_equal}()},
\code{\link{chk_all_equivalent}()},
\code{\link{chk_all_identical}()}
}
\concept{chk_alls}
chk/man/chk_double.Rd 0000644 0001762 0000144 00000002301 14436206156 014163 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-double.R
\name{chk_double}
\alias{chk_double}
\alias{vld_double}
\title{Check Double}
\usage{
chk_double(x, x_name = NULL)
vld_double(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if double using
\code{is.double(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_double()}: Validate Double
}}
\examples{
# chk_double
chk_double(1)
try(chk_double(1L))
# vld_double
vld_double(1)
vld_double(matrix(c(1, 2, 3, 4), nrow = 2L))
vld_double(double(0))
vld_double(numeric(0))
vld_double(NA_real_)
vld_double(1L)
vld_double(TRUE)
}
\seealso{
Other chk_typeof:
\code{\link{chk_character_or_factor}()},
\code{\link{chk_character}()},
\code{\link{chk_count}()},
\code{\link{chk_environment}()},
\code{\link{chk_factor}()},
\code{\link{chk_integer}()},
\code{\link{chk_list}()},
\code{\link{chk_logical}()}
}
\concept{chk_typeof}
chk/man/chk_tz.Rd 0000644 0001762 0000144 00000002043 14436206156 013351 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-tz.R
\name{chk_tz}
\alias{chk_tz}
\alias{vld_tz}
\title{Check Time Zone}
\usage{
chk_tz(x, x_name = NULL)
vld_tz(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if non-missing valid scalar timezone using
\code{is.character(x) && length(x) == 1L && !anyNA(x) && x \%in\% OlsonNames()}
}
\section{Functions}{
\itemize{
\item \code{vld_tz()}: Validate Time Zone
}}
\examples{
chk_tz("UTC")
try(chk_tz("TCU"))
vld_tz("UTC")
vld_tz("TCU")
}
\seealso{
Other chk_scalars:
\code{\link{chk_date_time}()},
\code{\link{chk_date}()},
\code{\link{chk_number}()},
\code{\link{chk_scalar}()},
\code{\link{chk_string}()},
\code{\link{chk_whole_number}()}
}
\concept{chk_scalars}
chk/man/chk_all_identical.Rd 0000644 0001762 0000144 00000002302 14436206156 015476 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-all-identical.R
\name{chk_all_identical}
\alias{chk_all_identical}
\alias{vld_all_identical}
\title{Check All Identical}
\usage{
chk_all_identical(x, x_name = NULL)
vld_all_identical(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks all elements in x identical using
\code{length(x) < 2L || all(vapply(x, vld_identical, TRUE, y = x[[1]]))}
\strong{Pass}: \code{c(1, 1, 1)}, \code{list(1, 1)}
\strong{Fail}: \code{c(1, 1.0000001)}, \code{list(1, NA)}
}
\section{Functions}{
\itemize{
\item \code{vld_all_identical()}: Validate All Identical
}}
\examples{
# chk_all_identical
chk_all_identical(c(1, 1))
try(chk_all_identical(c(1, 1.1)))
# vld_all_identical
vld_all_identical(c(1, 1))
}
\seealso{
Other chk_alls:
\code{\link{chk_all_equal}()},
\code{\link{chk_all_equivalent}()},
\code{\link{chk_all}()}
}
\concept{chk_alls}
chk/man/chk_used.Rd 0000644 0001762 0000144 00000001336 14436206156 013660 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-used.R
\name{chk_used}
\alias{chk_used}
\alias{vld_used}
\title{Check ... Used}
\usage{
chk_used(...)
vld_used(...)
}
\arguments{
\item{...}{Additional arguments.}
}
\value{
The \code{chk_} function throws an informative error if the test fails.
}
\description{
Checks if is ... used using
\code{length(list(...)) != 0L}
}
\section{Functions}{
\itemize{
\item \code{vld_used()}: Validate ... Used
}}
\examples{
# chk_used
fun <- function(x, ...) {
chk_used(...)
x
}
try(fun(1))
fun(1, 2)
# vld_used
fun <- function(x, ...) {
vld_used(...)
}
fun(1)
fun(1, 2)
}
\seealso{
Other chk_ellipsis:
\code{\link{chk_unused}()}
}
\concept{chk_ellipsis}
chk/man/check_values.Rd 0000644 0001762 0000144 00000003063 14436206156 014526 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check-values.R
\name{check_values}
\alias{check_values}
\title{Check Values and Class}
\usage{
check_values(x, values, x_name = NULL)
}
\arguments{
\item{x}{The object to check.}
\item{values}{An atomic vector specifying the S3 class and possible values.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
An informative error if the test fails or an invisible copy of x.
}
\description{
Checks values and S3 class of an atomic object.
}
\details{
To check the class simply pass a vector of the desired class.
To check that x does not include missing values pass
a single non-missing value (of the correct class).
To allow it to include missing values include a missing value.
To check that it only includes missing values only pass
a missing value (of the correct class).
To check the range of the values in x pass two non-missing values
(as well as the missing value if required).
To check that x only includes specific values
pass three or more non-missing values.
In the case of a factor ensure values has two levels to
check that the levels of x are an ordered superset of the levels of value
and three or more levels to check that they are identical.
}
\examples{
check_values(1, numeric(0))
check_values(1, 2)
try(check_values(1, 1L))
try(check_values(NA_real_, 1))
}
\seealso{
Other check:
\code{\link{check_data}()},
\code{\link{check_dim}()},
\code{\link{check_dirs}()},
\code{\link{check_files}()},
\code{\link{check_key}()},
\code{\link{check_names}()}
}
\concept{check}
chk/man/chk_not_null.Rd 0000644 0001762 0000144 00000001610 14436206156 014545 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-not-null.R
\name{chk_not_null}
\alias{chk_not_null}
\alias{vld_not_null}
\title{Check not NULL}
\usage{
chk_not_null(x, x_name = NULL)
vld_not_null(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if not NULL using
\code{!is.null(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_not_null()}: Validate Not NULL
}}
\examples{
# chk_not_null
try(chk_not_null(NULL))
chk_not_null(1)
# vld_not_null
vld_not_null(1)
vld_not_null(NULL)
}
\seealso{
Other chk_nulls:
\code{\link{chk_null}()}
}
\concept{chk_nulls}
chk/man/chk_unique.Rd 0000644 0001762 0000144 00000002672 14436206156 014232 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-unique.R
\name{chk_unique}
\alias{chk_unique}
\alias{vld_unique}
\title{Check Unique}
\usage{
chk_unique(x, incomparables = FALSE, x_name = NULL)
vld_unique(x, incomparables = FALSE)
}
\arguments{
\item{x}{The object to check.}
\item{incomparables}{A vector of values that cannot be compared.
FALSE means that all values can be compared.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if unique using
\code{!anyDuplicated(x, incomparables = incomparables)}
}
\section{Functions}{
\itemize{
\item \code{vld_unique()}: Validate Unique
}}
\examples{
# chk_unique
chk_unique(c(NA, 2))
try(chk_unique(c(NA, NA, 2)))
chk_unique(c(NA, NA, 2), incomparables = NA)
# vld_unique
vld_unique(NULL)
vld_unique(numeric(0))
vld_unique(c(NA, 2))
vld_unique(c(NA, NA, 2))
vld_unique(c(NA, NA, 2), incomparables = NA)
}
\seealso{
Other chk_misc:
\code{\link{chk_length}()},
\code{\link{chk_match}()},
\code{\link{chk_missing}()},
\code{\link{chk_named}()},
\code{\link{chk_not_any_na}()},
\code{\link{chk_not_empty}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_sorted}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/chk_wnum.Rd 0000644 0001762 0000144 00000002606 14436206156 013707 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-wnum.R
\name{chk_wnum}
\alias{chk_wnum}
\alias{vld_wnum}
\title{Check Whole Numeric Scalar}
\usage{
chk_wnum(x, x_name = NULL)
vld_wnum(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if whole numeric scalar using
\code{is.numeric(x) && length(x) == 1L && (is.integer(x) || vld_true(all.equal(x, trunc(x))))}
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}
\section{Functions}{
\itemize{
\item \code{vld_wnum()}: Validate Whole Numeric Scalar
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}}
\examples{
# chk_wnum
chk_wnum(1)
try(chk_wnum(1.1))
# vld_wnum
vld_wnum(1)
vld_wnum(double(0))
vld_wnum(NA_real_)
vld_wnum(c(1, 1))
vld_wnum(1L)
}
\seealso{
Other deprecated:
\code{\link{chk_chr}()},
\code{\link{chk_dbl}()},
\code{\link{chk_deprecated}}
}
\concept{deprecated}
chk/man/deparse_backtick_chk.Rd 0000644 0001762 0000144 00000001533 14436206156 016175 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{deparse_backtick_chk}
\alias{deparse_backtick_chk}
\alias{backtick_chk}
\alias{unbacktick_chk}
\title{Deparse Backtick}
\usage{
deparse_backtick_chk(x)
backtick_chk(x)
unbacktick_chk(x)
}
\arguments{
\item{x}{A substituted object to deparse.}
}
\value{
A string of the backticked substituted object.
}
\description{
\code{deparse_backtick_chk} is a wrapper on \code{\link[=deparse]{deparse()}}
and \code{backtick_chk}.
}
\details{
It is exported to allow users to easily construct their own \code{chk_} functions.
}
\section{Functions}{
\itemize{
\item \code{backtick_chk()}: Backtick
\item \code{unbacktick_chk()}: Unbacktick
}}
\examples{
# deparse_backtick_chk
deparse_backtick_chk(2)
deparse_backtick_chk(2^2)
}
\seealso{
\code{\link[=deparse]{deparse()}}
}
chk/man/chk_logical.Rd 0000644 0001762 0000144 00000002253 14436206156 014331 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-logical.R
\name{chk_logical}
\alias{chk_logical}
\alias{vld_logical}
\title{Check Logical}
\usage{
chk_logical(x, x_name = NULL)
vld_logical(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if logical using
\code{is.logical(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_logical()}: Validate Logical
}}
\examples{
# chk_logical
chk_logical(TRUE)
try(chk_logical(1))
# vld_logical
vld_logical(TRUE)
vld_logical(matrix(TRUE))
vld_logical(logical(0))
vld_logical(NA)
vld_logical(1)
vld_logical("TRUE")
}
\seealso{
Other chk_typeof:
\code{\link{chk_character_or_factor}()},
\code{\link{chk_character}()},
\code{\link{chk_count}()},
\code{\link{chk_double}()},
\code{\link{chk_environment}()},
\code{\link{chk_factor}()},
\code{\link{chk_integer}()},
\code{\link{chk_list}()}
}
\concept{chk_typeof}
chk/man/message_chk.Rd 0000644 0001762 0000144 00000002423 14436206156 014342 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/err.R
\name{message_chk}
\alias{message_chk}
\title{Construct Tidyverse Style Message}
\usage{
message_chk(..., n = NULL, tidy = TRUE)
}
\arguments{
\item{...}{Multiple objects that are converted to a string using
\code{paste0(..., collapse = '')}.}
\item{n}{The value of n for converting \code{sprintf}-like types.}
\item{tidy}{A flag specifying whether capitalize the first character and add a missing period.}
}
\value{
A string of the message.
}
\description{
If \code{tidy = TRUE} constructs a tidyverse style message by
}
\details{
\itemize{
\item Capitalizing the first character if possible.
\item Adding a trailing . if missing.
}
Also if \code{n != NULL} replaces the recognized \code{sprintf}-like types.
}
\section{\code{sprintf}-like types}{
The following recognized \code{sprintf}-like types can be used in a message:
\describe{
\item{\code{n}}{The value of n.}
\item{\code{s}}{'' if n == 1 otherwise 's'}
\item{\code{r}}{'is' if n == 1 otherwise 'are'}
\item{\code{y}}{'y' if n == 1 otherwise 'ie'}
}
}
\examples{
message_chk("there \%r \%n", " problem director\%y\%s")
message_chk("there \%r \%n", " problem director\%y\%s", n = 1)
message_chk("There \%r \%n", " problem director\%y\%s.", n = 3)
}
chk/man/chk_sorted.Rd 0000644 0001762 0000144 00000002155 14436206156 014220 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-sorted.R
\name{chk_sorted}
\alias{chk_sorted}
\alias{vld_sorted}
\title{Check Sorted}
\usage{
chk_sorted(x, x_name = NULL)
vld_sorted(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is sorted using
\code{is.unsorted(x, na.rm = TRUE)}
}
\section{Functions}{
\itemize{
\item \code{vld_sorted()}: Validate Sorted
}}
\examples{
# chk_sorted
chk_sorted(1:2)
try(chk_sorted(2:1))
# vld_sorted
vld_sorted(1:2)
vld_sorted(2:1)
}
\seealso{
Other chk_misc:
\code{\link{chk_length}()},
\code{\link{chk_match}()},
\code{\link{chk_missing}()},
\code{\link{chk_named}()},
\code{\link{chk_not_any_na}()},
\code{\link{chk_not_empty}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_unique}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/chk_not_any_na.Rd 0000644 0001762 0000144 00000002605 14436206156 015045 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-not-any-na.R
\name{chk_not_any_na}
\alias{chk_not_any_na}
\alias{vld_not_any_na}
\title{Check Not Any Missing Values}
\usage{
chk_not_any_na(x, x_name = NULL)
vld_not_any_na(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if not any missing values using
\code{!anyNA(x)}
\strong{Pass}: \code{1}, \code{1:2}, \code{"1"}, \code{logical(0)}.
\strong{Fail}: \code{NA}, \code{c(1, NA)}.
}
\section{Functions}{
\itemize{
\item \code{vld_not_any_na()}: Validate Not Any Missing Values
}}
\examples{
# chk_not_any_na
chk_not_any_na(1)
try(chk_not_any_na(NA))
# vld_not_any_na
vld_not_any_na(1)
vld_not_any_na(1:2)
vld_not_any_na(NA_real_)
vld_not_any_na(integer(0))
vld_not_any_na(c(NA, 1))
vld_not_any_na(TRUE)
}
\seealso{
Other chk_misc:
\code{\link{chk_length}()},
\code{\link{chk_match}()},
\code{\link{chk_missing}()},
\code{\link{chk_named}()},
\code{\link{chk_not_empty}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_sorted}()},
\code{\link{chk_unique}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/chk_null_or.Rd 0000644 0001762 0000144 00000001442 14436206156 014370 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-null-or.R
\name{chk_null_or}
\alias{chk_null_or}
\title{Check NULL Or}
\usage{
chk_null_or(x, chk, ..., vld, x_name = NULL)
}
\arguments{
\item{x}{The object to check.}
\item{chk}{A chk function. Soft-deprecated for vld. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}}
\item{...}{Arguments passed to chk.}
\item{vld}{A vld function.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
An informative error if the test fails.
}
\description{
Checks if NULL or passes test.
}
\examples{
chk_null_or(NULL, chk_number)
chk_null_or(1, chk_number)
try(chk_null_or("1", chk_number))
}
chk/man/chk_factor.Rd 0000644 0001762 0000144 00000002174 14436206156 014177 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-factor.R
\name{chk_factor}
\alias{chk_factor}
\alias{vld_factor}
\title{Check Factor}
\usage{
chk_factor(x, x_name = NULL)
vld_factor(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if factor using
\code{is.factor(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_factor()}: Validate Factor
}}
\examples{
# chk_factor
chk_factor(factor("1"))
try(chk_factor("1"))
# vld_factor
vld_factor(factor("1"))
vld_factor(factor(0))
vld_factor("1")
vld_factor(1L)
}
\seealso{
Other chk_typeof:
\code{\link{chk_character_or_factor}()},
\code{\link{chk_character}()},
\code{\link{chk_count}()},
\code{\link{chk_double}()},
\code{\link{chk_environment}()},
\code{\link{chk_integer}()},
\code{\link{chk_list}()},
\code{\link{chk_logical}()}
}
\concept{chk_typeof}
chk/man/chk_scalar.Rd 0000644 0001762 0000144 00000002010 14436206156 014153 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-scalar.R
\name{chk_scalar}
\alias{chk_scalar}
\alias{vld_scalar}
\title{Check Scalar}
\usage{
chk_scalar(x, x_name = NULL)
vld_scalar(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is a vector using
\code{length(x) == 1L}
}
\section{Functions}{
\itemize{
\item \code{vld_scalar()}: Validate Scalar
}}
\examples{
# chk_scalar
chk_scalar(1)
chk_scalar(list(1))
try(chk_scalar(1:2))
# vld_scalar
vld_scalar(1)
}
\seealso{
Other chk_scalars:
\code{\link{chk_date_time}()},
\code{\link{chk_date}()},
\code{\link{chk_number}()},
\code{\link{chk_string}()},
\code{\link{chk_tz}()},
\code{\link{chk_whole_number}()}
}
\concept{chk_scalars}
chk/man/chk_chr.Rd 0000644 0001762 0000144 00000002507 14436206156 013475 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-chr.R
\name{chk_chr}
\alias{chk_chr}
\alias{vld_chr}
\title{Check Character Scalar}
\usage{
chk_chr(x, x_name = NULL)
vld_chr(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if character scalar using
\code{is.character(x) && length(x) == 1L}
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}
\section{Functions}{
\itemize{
\item \code{vld_chr()}: Validate Character Scalar
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
}}
\examples{
chk_chr("a")
try(chk_chr(1))
# vld_chr
vld_chr("")
vld_chr("a")
vld_chr(NA_character_)
vld_chr(c("a", "b"))
vld_chr(1)
}
\seealso{
Other deprecated:
\code{\link{chk_dbl}()},
\code{\link{chk_deprecated}},
\code{\link{chk_wnum}()}
}
\concept{chk_character}
\concept{deprecated}
chk/man/chk_character_or_factor.Rd 0000644 0001762 0000144 00000002754 14436206156 016717 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-character-or-factor.R
\name{chk_character_or_factor}
\alias{chk_character_or_factor}
\alias{vld_character_or_factor}
\title{Check Character or Factor}
\usage{
chk_character_or_factor(x, x_name = NULL)
vld_character_or_factor(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if character or factor using
\code{is.character(x) || is.factor(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_character_or_factor()}: Validate Character or Factor
}}
\examples{
# chk_character_or_factor
chk_character_or_factor("1")
chk_character_or_factor(factor("1"))
try(chk_character(1))
# vld_character_or_factor
vld_character_or_factor("1")
vld_character_or_factor(matrix("a"))
vld_character_or_factor(character(0))
vld_character_or_factor(NA_character_)
vld_character_or_factor(1)
vld_character_or_factor(TRUE)
vld_character_or_factor(factor("text"))
}
\seealso{
Other chk_typeof:
\code{\link{chk_character}()},
\code{\link{chk_count}()},
\code{\link{chk_double}()},
\code{\link{chk_environment}()},
\code{\link{chk_factor}()},
\code{\link{chk_integer}()},
\code{\link{chk_list}()},
\code{\link{chk_logical}()}
}
\concept{chk_typeof}
chk/man/chk_not_empty.Rd 0000644 0001762 0000144 00000002665 14436206156 014744 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-not-empty.R
\name{chk_not_empty}
\alias{chk_not_empty}
\alias{vld_not_empty}
\title{Check Not Empty}
\usage{
chk_not_empty(x, x_name = NULL)
vld_not_empty(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if not empty using
\code{length(x) != 0L}
\strong{Pass}: \code{1}, \code{1:2}, \code{NA}, \code{matrix(1:3)}, \code{list(1)}, \code{data.frame(x = 1)}.
\strong{Fail}: \code{NULL}, \code{logical(0)}, \code{list()}, \code{data.frame()}.
}
\section{Functions}{
\itemize{
\item \code{vld_not_empty()}: Validate Not Empty
}}
\examples{
# chk_not_empty
chk_not_empty(1)
try(chk_not_empty(numeric(0)))
# vld_not_empty
vld_not_empty(1)
vld_not_empty(matrix(1:3))
vld_not_empty(character(0))
vld_not_empty(list(1))
vld_not_empty(NULL)
vld_not_empty(list())
}
\seealso{
Other chk_misc:
\code{\link{chk_length}()},
\code{\link{chk_match}()},
\code{\link{chk_missing}()},
\code{\link{chk_named}()},
\code{\link{chk_not_any_na}()},
\code{\link{chk_not_missing}()},
\code{\link{chk_sorted}()},
\code{\link{chk_unique}()},
\code{\link{chk_valid_name}()}
}
\concept{chk_misc}
chk/man/err.Rd 0000644 0001762 0000144 00000004161 14436206156 012662 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/err.R
\name{err}
\alias{err}
\alias{wrn}
\alias{msg}
\title{Stop, Warning and Message Messages}
\usage{
err(
...,
n = NULL,
tidy = TRUE,
.subclass = NULL,
class = NULL,
call = rlang::caller_call(3)
)
wrn(..., n = NULL, tidy = TRUE, .subclass = NULL, class = NULL)
msg(..., n = NULL, tidy = TRUE, .subclass = NULL, class = NULL)
}
\arguments{
\item{...}{zero or more objects which can be coerced to character
(and which are pasted together with no separator) or a single
condition object.}
\item{n}{The value of n for converting \code{sprintf}-like types.}
\item{tidy}{A flag specifying whether capitalize the first character and add a missing period.}
\item{.subclass}{A string of the class of the error message.}
\item{class}{Subclass of the condition.}
\item{call}{The execution environment of a currently running
function, e.g. \code{call = caller_env()}. The corresponding function
call is retrieved and mentioned in error messages as the source
of the error.
You only need to supply \code{call} when throwing a condition from a
helper function which wouldn't be relevant to mention in the
message.
Can also be \code{NULL} or a \link[rlang:topic-defuse]{defused function call} to
respectively not display any call or hard-code a code to display.
For more information about error calls, see \ifelse{html}{\link[rlang:topic-error-call]{Including function calls in error messages}}{\link[rlang:topic-error-call]{Including function calls in error messages}}.}
}
\description{
The functions call \code{\link[=message_chk]{message_chk()}} to process
the message and then
\code{\link[rlang:abort]{rlang::abort()}}, \code{\link[rlang:abort]{rlang::warn()}} and
\code{\link[rlang:abort]{rlang::inform()}}, respectively.
}
\details{
The user can set the subclass.
}
\section{Functions}{
\itemize{
\item \code{err()}: Error
\item \code{wrn()}: Warning
\item \code{msg()}: Message
}}
\examples{
# err
try(err("there \%r \%n problem value\%s", n = 2))
# wrn
wrn("there \%r \%n problem value\%s", n = 2)
# msg
msg("there \%r \%n problem value\%s", n = 2)
}
chk/man/chk_list.Rd 0000644 0001762 0000144 00000002144 14436206156 013671 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chk-list.R
\name{chk_list}
\alias{chk_list}
\alias{vld_list}
\title{Check List}
\usage{
chk_list(x, x_name = NULL)
vld_list(x)
}
\arguments{
\item{x}{The object to check.}
\item{x_name}{A string of the name of object x or NULL.}
}
\value{
The \code{chk_} function throws an informative error if the test fails or
returns the original object if successful so it can used in pipes.
The \code{vld_} function returns a flag indicating whether the test was met.
}
\description{
Checks if is a list using
\code{is.list(x)}
}
\section{Functions}{
\itemize{
\item \code{vld_list()}: Validate List
}}
\examples{
# chk_list
chk_list(list())
try(chk_list(1))
# vld_list
vld_list(list())
vld_list(list(x = 1))
vld_list(mtcars)
vld_list(1)
vld_list(NULL)
}
\seealso{
Other chk_typeof:
\code{\link{chk_character_or_factor}()},
\code{\link{chk_character}()},
\code{\link{chk_count}()},
\code{\link{chk_double}()},
\code{\link{chk_environment}()},
\code{\link{chk_factor}()},
\code{\link{chk_integer}()},
\code{\link{chk_logical}()}
}
\concept{chk_typeof}
chk/man/figures/ 0000755 0001762 0000144 00000000000 14436206156 013245 5 ustar ligges users chk/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000001704 14436206156 017355 0 ustar ligges users