End-to-end scripts for harmonizing Canvas and REDCap survey exports, producing analysis-ready data, descriptive tables, and quick pre/post visuals for the DETECT clinician scale measures workstream.
- Canvas pre/post survey exports named exactly as the files in
data/canvas/. - REDCap control export plus data dictionary in
data/redcap/. data/csm_likert_numeric_data.csv– numeric summary of ABEM item means used by the visualization script.
data/– raw inputs and derived CSVs (Canvas, REDCap, and harmonized files).tables/– Word exports produced bytables.r.visualizations/– saved plot exports.data_harmonization.r– trims Canvas metadata, aligns variable names to REDCap, recodes factors, and writesdata/clinican_scale_measures_harmonized_analysis_data.csv.tables.r– builds Table 1 (sociodemographics) and Table 2 (ABEM item means) from the harmonized data.visualizations.r– readsdata/csm_likert_numeric_data.csvplus the harmonized data; saves pre/post mean dumbbell and response distribution plots.data_maps.r– shared mappings for variable names, factor levels, site champions, and descriptive ABEM item labels.renv*/renv.lock– dependency lockfile and project-local library managed byrenv.
- Place the Canvas and REDCap exports in
data/canvas/anddata/redcap/with the existing filenames. - Run
data_harmonization.rto:- remove Canvas metadata and quiz scoring fields,
- rename Canvas columns to REDCap variable names and dummy-code multi-select race responses,
- recode REDCap numeric codes to labeled factors and tag site champions,
- stack Canvas pre, Canvas post, and REDCap control into
data/clinican_scale_measures_harmonized_analysis_data.csv.
- Run
tables.rto enforce factor levels and writetables/table_1.docx(sociodemographics) andtables/table_2.docx(ABEM pre/post means). - Run
visualizations.rto generate:visualizations/likert_answer_mean_changes.png(Canvas pre vs post mean dumbbell plot usingdata/csm_likert_numeric_data.csv).visualizations/likert_answer_distributions.png(faceted pre/post response distributions from the harmonized data).
From R:
install.packages("renv") # if not already installed
renv::restore() # install locked package versions
source("data_harmonization.r")
source("tables.r")
source("visualizations.r")From the shell:
Rscript data_harmonization.r
Rscript tables.r
Rscript visualizations.rdata/clinican_scale_measures_harmonized_analysis_data.csv– stacked Canvas pre/post and REDCap control records with aligned variable names and readable labels.tables/table_1.docx– sociodemographics.tables/table_2.docx– ABEM item means with Canvas post minus pre deltas.visualizations/likert_answer_mean_changes.png– Canvas pre vs post mean dumbbell plot based ondata/csm_likert_numeric_data.csv.visualizations/likert_answer_distributions.png– saved histogram facets comparing pre/post response distributions by item.
- Canvas columns are renamed using
redcap_field_labels_pre/postand race text is dummy-coded viacanvas_to_redcap_race_map. - REDCap numeric codes are recoded to labeled factors for readability; site champions are tagged via
site_champions. - Table 1 drops race from the main sociodemographic table and handles it separately to account for multi-select responses.