Generates a visual report of a harmonized dossier in an HTML bookdown document, with summary figures and statistics for each harmonized variable. The report outputs can be grouped by a categorical variable.

harmonized_dossier_visualize(
  harmonized_dossier,
  bookdown_path,
  group_by = attributes(harmonized_dossier)$`Rmonize::harmonized_col_dataset`,
  harmonized_dossier_summary = NULL,
  dataschema = attributes(harmonized_dossier)$`Rmonize::DataSchema`,
  data_proc_elem = attributes(harmonized_dossier)$`Rmonize::Data Processing Element`,
  valueType_guess = FALSE,
  taxonomy = NULL
)

Arguments

harmonized_dossier

A list containing the harmonized dataset(s).

bookdown_path

A character string identifying the folder path where the bookdown report files will be saved.

group_by

A character string identifying the column in the dataset to use as a grouping variable. Elements will be grouped by this column.

harmonized_dossier_summary

A list which identifies an existing summary produced by harmonized_dossier_summarize() of the harmonized variables. Using this parameter can save time in generating the visual report.

dataschema

A DataSchema object.

data_proc_elem

A Data Processing Elements object.

valueType_guess

Whether the output should include a more accurate valueType that could be applied to the dataset. FALSE by default.

taxonomy

An optional data frame identifying a variable classification schema.

Value

A folder containing files for the bookdown site. To open the bookdown site in a browser, open 'docs/index.html', or use bookdown_open() with the folder path.

Details

A harmonized dossier is a named list containing one or more data frames, which are harmonized datasets. A harmonized dossier is generally the product of applying processing to a dossier object The name of each harmonized dataset (data frame) is taken from the reference input dataset. A harmonized dossier also contains the DataSchema and Data Processing Elements used in processing as attributes.

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 Data Processing Elements specifies the algorithms used to process input variables into harmonized variables in the DataSchema format. 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).

The valueType is a declared property of a variable that is required in certain functions to determine handling of the variables. Specifically, valueType refers to the OBiBa data type of a variable. The valueType is specified in a data dictionary in a column 'valueType' and can be associated with variables as attributes. Acceptable valueTypes include 'text', 'integer', 'decimal', 'boolean', datetime', 'date'. The full list of OBiBa valueType possibilities and their correspondence with R data types are available using valueType_list. The valueType can be used to coerce the variable to the corresponding data type.

A taxonomy is a classification schema that can be defined for variable attributes. A taxonomy is usually extracted from an Opal environment, and a taxonomy object is a data frame that must contain at least the columns taxonomy, vocabulary, and terms. Additional details about Opal taxonomies are available online.

Examples

{

# Use Rmonize_DEMO to run examples.

library(fs)
 
harmonized_dossier <- Rmonize_DEMO$harmonized_dossier
harmonized_dossier_summary <- Rmonize_DEMO$harmonized_dossier_summary
 
if(dir_exists(tempdir())) dir_delete(tempdir())
bookdown_path <- tempdir()
 
harmonized_dossier_visualize(
   harmonized_dossier,
   bookdown_path = bookdown_path,
   harmonized_dossier_summary = harmonized_dossier_summary)

# To open the file in browser, open 'bookdown_path/docs/index.html'.
# Or use bookdown_open(bookdown_path) function

}
#> Warning: 
#> An additional variable `Rmonize::harmonized_col_dataset` has been created
#> with harmonized dataset names as values for each harmonized dataset.
#> 
#> Useful tip:
#> To avoid this message, we recommend to set `harmonized_col_dataset` as a 
#> categorical variable DataSchema, or to set `add_col_dataset` = FALSE.
#> 1/23                   
#> 2/23 [unnamed-chunk-1] 
#> 3/23                   
#> 4/23 [unnamed-chunk-2] 
#> 5/23                   
#> 6/23 [unnamed-chunk-3] 
#> 7/23                   
#> 8/23 [unnamed-chunk-4] 
#> 9/23                   
#> 10/23 [unnamed-chunk-5] 
#> 11/23                   
#> 12/23 [unnamed-chunk-6] 
#> 13/23                   
#> 14/23 [figures-plot12-1]
#> 15/23                   
#> 16/23 [unnamed-chunk-7] 
#> 17/23                   
#> 18/23 [unnamed-chunk-8] 
#> 19/23                   
#> 20/23 [unnamed-chunk-9] 
#> 21/23                   
#> 22/23 [figures-plot12-2]
#> 23/23                   
#> "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS bookdownproj.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output bookdownproj.html --lua-filter "C:\Users\guill\AppData\Local\R\win-library\4.3\bookdown\rmarkdown\lua\custom-environment.lua" --lua-filter "C:\Users\guill\AppData\Local\R\win-library\4.3\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\guill\AppData\Local\R\win-library\4.3\rmarkdown\rmarkdown\lua\latex-div.lua" --lua-filter "C:\Users\guill\AppData\Local\R\win-library\4.3\rmarkdown\rmarkdown\lua\anchor-sections.lua" --metadata-file "C:\Users\guill\AppData\Local\Temp\RtmpqeHphB\file3b245f503270" --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\Users\guill\AppData\Local\R\win-library\4.3\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --css style.css --mathjax --include-in-header "C:\Users\guill\AppData\Local\Temp\RtmpqeHphB\rmarkdown-str3b24194c763a.html" 
#> 
#> 
#> To edit your file, You can use the function `bookdown_open('C:\Users\guill\AppData\Local\Temp\RtmpqeHphB')`
#> (Compatibility tested on Chrome, Edge and Mozilla)
#>