coerce_dt | R Documentation |
data.table
sProvides consistent coercion of inputs to data.table with error handling, column checking, and optional selection.
coerce_dt(
data,
select = NULL,
required_cols = select,
forbidden_cols = NULL,
group = FALSE,
dates = FALSE,
copy = TRUE,
msg_required = "The following columns are required: ",
msg_forbidden = "The following columns are forbidden: "
)
data |
Any of the types supported by |
select |
An optional character vector of columns to return; unchecked
n.b. it is an error to include ".group"; use |
required_cols |
An optional character vector of required columns |
forbidden_cols |
An optional character vector of forbidden columns |
group |
A logical; ensure the presence of a |
dates |
A logical; ensure the presence of |
copy |
A logical; if |
msg_required |
A character string; for |
msg_forbidden |
A character string; for |
This function provides a single-point function for getting a "local"
version of data provided by the user, in the internally used data.table
format. It also enables selectively copying versus not, as well as checking
for the presence and/or absence of various columns.
While it is intended to address garbage in from the user, it does not generally attempt to address garbage in from the developer - e.g. if asking for overlapping required and forbidden columns (though that will lead to an always-error condition).
A data.table
; the returned object will be a copy, unless
copy = FALSE
, in which case modifications are made in-place
Utility functions
aggregate_rolling_sum()
,
coerce_date()
,
date_to_numeric_modulus()
,
get_internal_timestep()
,
is.Date()
,
stan_fns_as_string()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.