R6 project object for REDCapSync
Main class for managing REDCap data, metadata, and sync operations.
Users should construct objects using setup_project().
See also
setup_project for initializing the project object.'
Methods
Method new()
The end user will not see project$new(). This is handled internally.
Users should construct objects using setup_project(). The remain
methods will be accessible to any user.
Usage
REDCapSync_project$new(project)Method sync()
Updates the REDCap data for (project object) by checking REDCap log.
Usage
REDCapSync_project$sync(
summarize = TRUE,
save_to_dir = TRUE,
hard_check = FALSE,
hard_reset = FALSE
)Arguments
summarizeLogical (TRUE/FALSE). If TRUE, summarizes data to directory.
save_to_dirLogical (TRUE/FALSE). If TRUE, saves the updated data to the directory. Default is
TRUE.hard_checkWill check REDCap even if not due (see
sync_frequencyparameter fromsetup_project())hard_resetLogical. If
TRUE, overwrite existing summary files with the same name. Default isFALSE.
Method add_summary()
Add a new summary entry
Usage
REDCapSync_project$add_summary(
summary_name,
transformation_type = "default",
merge_form_name = "merged",
filter_field = NULL,
filter_choices = NULL,
filter_list = NULL,
filter_strict = TRUE,
field_names = NULL,
form_names = NULL,
exclude_identifiers = TRUE,
exclude_free_text = FALSE,
date_handling = "none",
labelled = TRUE,
clean = TRUE,
drop_blanks = FALSE,
drop_missing_codes = FALSE,
drop_others = NULL,
include_metadata = TRUE,
include_records = TRUE,
include_users = TRUE,
include_log = FALSE,
annotate_from_log = TRUE,
with_links = TRUE,
separate = FALSE,
use_csv = FALSE,
dir_other = NULL,
file_name = NULL,
hard_reset = FALSE
)Arguments
summary_nameCharacter. The name of the summary from which to generate the summary. *If you provide
summary_nameall other parameters are inherited according to what was set withadd_project_summary.transformation_typeCharacter vector. Default is "default". Also have "none", "flat", "merge_non_repeating" "default" first merges non-repeating and if there are repeating forms it merges non-repeating variables to the right of repeating instruments "flat" is one-record, one-row, even if there are repeating forms "none" does not transform anything "merge_non_repeating" still merges all non-repeating instruments but does not merge them to repeating instruments
merge_form_nameA character string representing the name of the merged form. Default is "merged".
filter_fieldCharacter. The name of the field in the database to filter on.
filter_choicesVector. The values of
filter_fieldused to define the summary.filter_listVector. The values of
filter_fieldused to define the summary.filter_strictLogical. If
TRUE, all forms will be filtered by criteria. IfFALSE, will convert original filter to id column and filter all other forms by that record. Default isTRUE.field_namesCharacter vector. Names of specific fields to include in the summary. Default is
NULL, which includes all fields.form_namesCharacter vector. Names of forms to include in the summary. Default is
NULL, which includes all forms.exclude_identifiersLogical. Whether to exlude identifiers in the data in the summary. Default is
TRUE.exclude_free_textLogical for excluding free text. Default is
FALSE.date_handlingcharacter string. One of
none,exclude_dates,random_shift_by_record,random_shift_by_project,zero_by_record, orzero_by_projectrandom shift is +/- 90 unless changed with optionslabelledLogical. If
TRUE, the data will be converted to labelled. Default isTRUE.cleanLogical. If
TRUE, the data will be cleaned before summarizing. Default isTRUE. If missing codes present AND number or date type, R will convert to those to NA and would make that variable not upload compatibledrop_blanksLogical. If
TRUE, records with blank fields will be dropped. Default isTRUE.drop_missing_codesLogical. If
TRUE, will convert missing codes to NA. Default isFALSE.drop_othersCharacter vector of other values that should be dropped.
include_metadataLogical. If
TRUE, metadata will be included in the summary. Default isTRUE.include_recordsLogical. If
TRUE, a record summary will be included in the generated summary. Default isTRUE.include_usersLogical. If
TRUE, user-related information will be included in the summary. Default isTRUE.include_logLogical. If
TRUE, the log of changes will be included in the summary. Default isTRUE.annotate_from_logLogical. If
TRUE, the metadata, users, and records will be annotated using the log. Default isTRUE.with_linksOptional logical (TRUE/FALSE) for including links in Excel sheets. Default is
FALSE.separateOptional logical (TRUE/FALSE) separating each form into separate files as opposed to multi-tab Excel. Default is
FALSE.use_csvLogical (TRUE/FALSE). If TRUE, uses CSV files for data storage. Default is
FALSEdir_otherCharacter. The directory where the summary file will be saved. Default is the
outputfolder within the database directory.file_nameCharacter. The base name of the file where the summary will be saved. Default is
<project$project_name>_<summary_name>.hard_resetLogical. If
TRUE, overwrite existing summary files with the same name. Default isFALSE.
Method add_field()
Add a new summary entry
Usage
REDCapSync_project$add_field(
field_name,
form_name,
field_type,
field_type_R = NA,
field_label = NA,
select_choices_or_calculations = NA,
field_note = NA,
identifier = "",
units = NA,
data_func = NA
)Arguments
field_nameCharacter. The name of the field to which the transformation will be applied.
form_nameCharacter. The name of the form containing the field.
field_typeCharacter. The type of the field in REDCap (e.g., "text", "checkbox", "dropdown").
field_type_RCharacter. The corresponding R data type for the field. Default is
NA.field_labelCharacter. The label for the field. Default is
NA.select_choices_or_calculationsCharacter. A string specifying the choices (for dropdown, radio, or checkbox fields) or calculations (for calculated fields). Default is
NA.field_noteCharacter. An optional note or comment for the field. Default is
NA.identifierCharacter. A string indicating whether the field is an identifier (e.g., "Y" for yes). Default is an empty string (
"").unitsCharacter. The units of measurement for the field, if applicable. Default is
NA.data_funcFunction or NA. An optional function to transform or validate the data in the field. Default is
NA.
