specify_date() creates a function that will call stabilize_date() with
the provided arguments. specify_date_scalar() creates a function that will
call stabilize_date_scalar() with the provided arguments.
Usage
specify_date(
allow_null = TRUE,
allow_na = TRUE,
min_size = NULL,
max_size = NULL,
unique = FALSE,
min_value = NULL,
max_value = NULL,
allowed_values = NULL
)
specify_date_scalar(
allow_null = FALSE,
allow_zero_length = FALSE,
allow_na = TRUE,
min_value = NULL,
max_value = NULL,
allowed_values = NULL
)Arguments
- allow_null
(
logical(1)) Is NULL an acceptable value?- allow_na
(
logical(1)) Are NA values ok?- min_size
(
integer(1)) The minimum size of the object. Object size will be tested usingvctrs::vec_size().- max_size
(
integer(1)) The maximum size of the object. Object size will be tested usingvctrs::vec_size().- unique
(
logical(1)) Should all elements inxbe distinct?- min_value
(
numeric(1)) The lowest allowed value forx. IfNULL(default) values are not checked.- max_value
(
numeric(1)) The highest allowed value forx. IfNULL(default) values are not checked.- allowed_values
A vector of permitted values (coerced to the target type).
NULL(default) skips the check.NAvalues inxare permitted independently ofallowed_values, subject toallow_na.- allow_zero_length
(
logical(1)) Are zero-length vectors acceptable?
Value
A function of class "stbl_specified_fn" that calls
stabilize_date() or stabilize_date_scalar() with the provided
arguments. The generated function will also accept ... for additional
arguments to pass to stabilize_date() or stabilize_date_scalar(). You
can copy/paste the body of the resulting function if you want to provide
additional context or functionality.
See also
Other date functions:
stabilize_date(),
stabilize_date_scalar(),
to_date(),
to_date_scalar()
Other specification functions:
specify_chr(),
specify_dbl(),
specify_df(),
specify_dttm(),
specify_dur(),
specify_fct(),
specify_int(),
specify_lgl(),
specify_lst(),
specify_time()
Examples
stabilize_recent <- specify_date(min_value = "2000-01-01")
stabilize_recent("2024-01-01")
#> [1] "2024-01-01"
try(stabilize_recent("1999-12-31"))
#> Error in eval(expr, envir) : `"1999-12-31"` must be >= 2000-01-01.
#> ✖ "1999-12-31" is too low.