download-case-projects: Download New Interview Tool Data

download-case-projectsR Documentation

Download New Interview Tool Data

Description

download_nit() downloads records from the New Interview Tool (NIT) project

download_nca() downloads records from the New Case Assignment (NCA) project

Usage

download_nit(
  api_token = Sys.getenv("redcap_NIT_token"),
  headers = c("raw", "label"),
  values = c("raw", "label"),
  filter = NULL,
  dir = "V:/EPI DATA ANALYTICS TEAM/COVID SANDBOX REDCAP DATA/Data for R/nit/",
  file = paste0("nit_data_", Sys.Date(), ".csv"),
  force = FALSE
)

download_nca(
  api_token = Sys.getenv("redcap_NCA_token"),
  headers = c("raw", "label"),
  values = c("raw", "label"),
  filter = NULL,
  dir = "V:/EPI DATA ANALYTICS TEAM/COVID SANDBOX REDCAP DATA/Data for R/nca/",
  file = paste0("nca_data_", Sys.Date(), ".csv"),
  force = FALSE
)

Arguments

api_token

character. API token/key for accessing the project programmatically. Best practice is to set as an environment variable and retrieve using Sys.getenv("token_environment_variable"). See env_vars for more information.

headers

"raw" or "label". Should column names ("headers") be exported as the raw variable names ("raw", the default) or the label shown in the UI ("label")?

values

"raw" or "label". Should values in multiple-choice and checkbox fields be exported as the raw coded value ("raw", the default) or the label for the coded value ("label")?

filter

character. REDcap filtering logic to apply prior to download. This must be in the REDcap logic syntax.

dir

character. Directory to save data; this should usually remain unchanged.

file

character. File name for data; this should usually remain unchanged. The resulting file will always have a "csv" extension; if you pass a file name without a "csv" extension, the function will replace it with a warning.

force

Should the download overwrite an existing file, if one exists? The default is FALSE, which errors if an existing file is found.

Value

The path to the data as an fs_path character vector

Examples

## Not run: 
  # Download the current NIT data
  download_nit()

  # Download NIT and load immediately
  nit_data <- load_nit(download_nit())

  # Do the same with pipe (`%>%`)
  nit_data <- download_nit() %>% load_nit()

  # Overwrite the previous file
  download_nit(force = TRUE)

  # Download NCA data
  download_nca()

  # Download NCA and overwrite previous file
  nca_data <- download_nca() %>% load_nca()

## End(Not run)

jesse-smith/coviData documentation built on Jan. 14, 2023, 11:08 a.m.