Create wide format data following a given spec
Source:R/build_adsl.R, R/build_bds.R, R/build_occds.R, and 1 more
build_x.RdExtract and reshape data from a single data set according to the given specification
as created by adam_spec_*(). In addition, an (updated) dictionary is returned along with
the md5 checksum of the specified file.
Usage
build_adsl(spec)
build_bds(
spec,
dupl_ctrl = list(values_fn = NULL, arrange = NULL),
names_ctrl = list(clean_fn = ~stringr::str_replace_all(.x, "[:punct:]|[:space:]", "_"),
names_sep = "_"),
rm = FALSE
)
build_occds(spec, values_fn_occds = NULL)Arguments
- spec
result of
adam_spec_*()- dupl_ctrl
bds only. A list with two entries
values_fnfunction to handle duplicates in pivoting step. see details section for default.arrangeexpression passed toarrange()optional sorting of data set prior to pivoting, e.g. in order to select the first/last value by date. defaults toNULL.
- names_ctrl
bds only. A list with two entries handling cleaning and renaming of columns after pivoting
clean_fndefaults tostringr::str_replace_all(.x, '[:punct:]|[:space:]', '_').names_sepdefaults to '_'
- rm
bds only. boolean. defaults to FALSE. if TRUE, a repeated measurement feature matrix with an additional
.rmtimecolumn is prepared. Only used, ifis.null(spec$rm).- values_fn_occds
occds only. function that is used to summarize values in the pivoting step, if multiple rows per observation unit are present. If
NULL, the maximum is used for numeric values and the last factor level is used for categorical values.
Value
A list with the following entries
dataa tibble in wide format with one row periddicta tibble listing the distinct combinations of columnsparam,label,unit,time,column,source(if provided).sourcea list passing thefileslot from the givenspecthat the created data set is based upon along with the md5 checksum of this file iffilewas provided, NULL otherwiseflag_tablebuild_adsl()only. flag table is passed fromspec$flag_tableslot
Details
Note that the output dictionary may differ from the dictionary created by adam_spec_*(),
as multiple features may be derived from a single parameter at different time points.
values_fn is passed to pivot_wider().
The default is function(x) {ifelse(all(is.numeric(x)), mean(x, na.rm = TRUE), na.omit(x)[1])}