Description

The des_scatterplot_matrix function provides Pearson correlation (r) for groups of numerical variables in the study data. These variable groups (expecting to show Pearson correlation) have to be specified in the cross-item level metadata.
The function provides a table with the list of variables and their correlation and pairwise correlation plots.

Usage and arguments

des_scatterplot_matrix(study_data = sd1, 
                       meta_data = "item_level", 
                       label_col = LABEL,
                       meta_data_cross_item = "cross-item_level")

The function has the following arguments:

  • study_data: mandatory, the data frame containing the measurements;
  • meta_data: mandatory, the data frame containing the item_level metadata.
  • meta_data_cross_item: mandatory, the data frame containing the cross-item_level metadata.
  • label_col: optional, the column in the metadata data frame containing the labels of all the variables in the study data.

Example output

To illustrate the output, we use the example synthetic data and metadata that are bundled with the dataquieR package. See the introductory tutorial for instructions on importing these files into R, as well as details on their structure and contents.

prep_load_workbook_like_file("meta_data_v2")
sd1 <- prep_get_data_frame("study_data")
des_scat <- des_scatterplot_matrix(study_data = sd1)

The function generates 3 outputs VariableGroupData, VariableGroupTable, and VariableGroupPlotList. The first two (VariableGroupData and VariableGroupTable) are exactly the same in this case, but used differently in the creation of a report.


Output 1: Summary data frame

The summary data frame is called using des_scat$VariableGroupData:

Either as an interactive data.tables table:

DT::datatable(des_scat$VariableGroupData, escape = FALSE)

Or as a kable:

VARIABLE_LIST cors max_cor
Blood pressure checks SBP_0 | DBP_0 cor(DBP_0, SBP_0) = 0.7655034 0.7655034


Output 2: Pairwise correlation plots

The matrix of the Pairwise correlation plots is called using des_scat$VariableGroupPlotList:

## Registered S3 method overwritten by 'GGally': method from +.gg ggplot2
## $`Blood pressure checks`

Please ignore the warning error messages about GGally and the error about argument "i", both come from the package GGally, and both are pointless.

Interpretation

Algorithm of the implementation

  1. From the cross-item metadata, determine group of variables for which is expected to calculate the Pairwise correlation.
  2. Calculate Pairwise correlation value for the specified variables.

Concept relations