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
)

Arguments

fn_path

is the location of the data, assumed to be the current path.

fn_root

the root name(s) of the file(s), typically the project name(s) (the part before DATA.)

fn_suffix_data

typically "DATA" to indicate this is the data

fn_suffix_R

typically "R" to indicate this is the R formatting file

fn_suffix_out

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

fn_ext_data

"*.csv" to specify the data filename extension, only csv is supported ("csv" is differnt from "CSV")

fn_ext_R

"*.r" to specify the R filename extension, ("r" is differnt from "R")

sw_return_dat

TRUE/FALSE to return the data object from the function

sw_save_RData

TRUE/FALSE to save an ".RData" file

Value

out_dat formatted data or invisible(NULL), depending on sw_return_dat

Details

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

Examples

if (FALSE) {
# dat_temp <-
#   e_REDCap_read_format_data(
#     fn_path   = "C:/Data/Project"
#   , fn_root   = "ProjectName"
#   )
}