R/02-harmo_process_harmonization.R
dataschema_extract.Rd
Generates a DataSchema from a Data Processing Elements.
dataschema_extract(data_proc_elem)
A Data Processing Elements object.
A list of data frame(s) named 'Variables' and (if any) 'Categories', with
Rmonize::class
'dataschema'.
The Data Processing Elements specifies the input elements and processing algorithms
to generate harmonized variables in the DataSchema formats. It is also
contains metadata used to generate documentation of the processing.
A Data Processing Elements object is a data frame with specific columns
used in data processing: dataschema_variable
, input_dataset
,
input_variables
, Mlstr_harmo::rule_category
and Mlstr_harmo::algorithm
.
To initiate processing, the first entry must be the creation of a harmonized
primary identifier variable (e.g., participant unique ID).
A DataSchema is the list of core variables to generate across datasets and
related metadata. A DataSchema object is a list of data frames with elements
named 'Variables' (required) and 'Categories' (if any). The 'Variables'
element must contain at least the name
column, and the 'Categories'
element must contain at least the variable
and name
columns to be usable
in any function. In 'Variables' the name
column must also have unique
entries, and in 'Categories' the combination of variable
and name
columns
must also be unique.
The object may be specifically formatted to be compatible with additional
Maelstrom Research software,
in particular Opal environments.
{
# Use Rmonize_examples to run examples.
library(dplyr)
dataschema <- dataschema_extract(Rmonize_examples$`Data_Processing_Element_no errors`)
glimpse(dataschema)
}
#> List of 1
#> $ Variables: tibble [9 × 3] (S3: tbl_df/tbl/data.frame)
#> ..$ name : chr [1:9] "adm_unique_id" "adm_study_id" "sdc_age_m" "sdc_marital_m" ...
#> ..$ label : chr [1:9] "adm_unique_id" "adm_study_id" "sdc_age_m" "sdc_marital_m" ...
#> ..$ valueType: chr [1:9] "text" "text" "text" "text" ...
#> ..- attr(*, "Rmonize::class")= chr "data_proc_elem"
#> - attr(*, "madshapR::class")= chr "data_dict_mlstr"
#> - attr(*, "Rmonize::class")= chr "dataschema_mlstr"