R/e_REDCap_read_format_data.R
e_REDCap_read_format_data.Rd
Read the files in the fn_path and find the most recent file (last alphabetically, which is by date based on REDCap file name convention of _yyyy-mm-dd_hhmm.) and read and format that given the R formatting file.
e_REDCap_read_format_data(
fn_path = getwd(),
fn_root = NULL,
fn_suffix_data = "_DATA_",
fn_suffix_R = "_R_",
fn_suffix_out = "",
fn_ext_data = "csv",
fn_ext_R = "r",
sw_return_dat = TRUE,
sw_save_RData = TRUE
)
is the location of the data, assumed to be the current path.
the root name(s) of the file(s), typically the project name(s) (the part before DATA.)
typically "DATA" to indicate this is the data
typically "R" to indicate this is the R formatting file
an added name to the outputted saved and formatted data files, maybe you want to add a date, a version number, or a another label
"*.csv" to specify the data filename extension, only csv is supported ("csv" is differnt from "CSV")
"*.r" to specify the R filename extension, ("r" is differnt from "R")
TRUE/FALSE to return the data object from the function
TRUE/FALSE to save an ".RData" file
out_dat formatted data or invisible(NULL)
, depending on sw_return_dat
For each project file:
Menu > Reports (Data Exports, Reports, and Stats) > All data
All data (all records and fields), Export Data
R Statistical Software
Click both of the R and CSV file icons
a. Save to your path
b. Name as: (default name) (fn_root)_DATA_yyyy-mm-dd_hhmm.csv, (fn_root)_R_yyyy-mm-dd_hhmm.csv
if (FALSE) {
# dat_temp <-
# e_REDCap_read_format_data(
# fn_path = "C:/Data/Project"
# , fn_root = "ProjectName"
# )
}