Coerce data.frame/tibble column data types to hub schema data types or character.
Source:R/coerce_to_hub_schema.R
coerce_to_hub_schema.Rd
Coerce data.frame/tibble column data types to hub schema data types or character.
Usage
coerce_to_hub_schema(
tbl,
config_tasks,
skip_date_coercion = FALSE,
as_arrow_table = FALSE,
output_type_id_datatype = c("from_config", "auto", "character", "double", "integer",
"logical", "Date")
)
coerce_to_character(tbl, as_arrow_table = FALSE)
Arguments
- tbl
a model output data.frame/tibble
- config_tasks
a list version of the content's of a hub's
tasks.json
config file created using functionhubUtils::read_config()
.- skip_date_coercion
Logical. Whether to skip coercing dates. This can be faster, especially for larger
tbl
s.- as_arrow_table
Logical. Whether to return an arrow table. Defaults to
FALSE
.- output_type_id_datatype
character string. One of
"from_config"
,"auto"
,"character"
,"double"
,"integer"
,"logical"
,"Date"
. Defaults to"from_config"
which uses the setting in theoutput_type_id_datatype
property in thetasks.json
config file if available. If the property is not set in the config, the argument falls back to"auto"
which determines theoutput_type_id
data type automatically from thetasks.json
config file as the simplest data type required to represent all output type ID values across all output types in the hub. When only point estimate output types (whereoutput_type_id
s areNA
,) are being collected by a hub, theoutput_type_id
column is assigned acharacter
data type when auto-determined. Other data type values can be used to override automatic determination. Note that attempting to coerceoutput_type_id
to a data type that is not valid for the data (e.g. trying to coerce"character"
values to"double"
) will likely result in an error or potentially unexpected behaviour so use with care.