Learn R Programming

psHarmonize (version 0.3.6)

harmonization: Harmonization Function

Description

This is the main function in the psHarmonize package. Takes a harmonization sheet as input, and returns a harmonization object (list with S3 class of 'psHarmonize'). Requires source data.frames to be in the global environment.

Usage

harmonization(
  harmonization_sheet,
  long_dataset = TRUE,
  wide_dataset = TRUE,
  error_log = TRUE,
  source_variables = TRUE,
  na_string = "NA",
  verbose = TRUE
)

Value

List of return objects with S3 class of 'psHarmonize'. Can be used as input for report function create_summary_report() and create_error_log_report().

Arguments

harmonization_sheet

Harmonization sheet input. Set of coding instructions

long_dataset

(TRUE/FALSE) Should the function return a long dataset?

wide_dataset

(TRUE/FALSE) Should the function return a wide dataset?

error_log

(TRUE/FALSE) Should the function return an error log?

source_variables

(TRUE/FALSE) Should the output datasets contain the original non modified values?

na_string

Character string of final recode value to be set to missing. Default is 'NA'. For example, if you use code_type of 'recode', and some of your final values are 'NA', they will be set to missing.

verbose

(TRUE/FALSE) Should the harmonization() function print the current progress to the console?

Details

Note: psHarmonize evaluates and runs code entered in the harmonization sheet. Make sure to only use harmonization sheets from authors you trust.

Examples

Run this code

# Running harmonization function with example harmonization sheet
harmonization_obj <- harmonization(harmonization_sheet = harmonization_sheet_example)

# Extracting harmonized long dataset (each row is a visit)
long_dataset <- harmonization_obj$long_dataset

# Extracting harmonized wide dataset (each row is a person)
# Visits are expressed in multiple columns
wide_dataset <- harmonization_obj$wide_dataset


Run the code above in your browser using DataLab