Setup
This is how you get REDCap turned into an R database…
library(REDCapSync)
projects <- get_projects() # get list of cached projects
View(projects) # show your previously saved projects
project <- setup_project(
short_name = "TEST_repeating",
redcap_base = "https://redcap.miami.edu/", # change to your institutions link
dir_path = getwd(), # or change to your intended file path
# force = T, # use this to force a refresh
merge_form_name = "patient",
use_csv = FALSE, # if you don't have Microsoft change to TRUE
auto_check_token = TRUE
)
You can set your REDCap token in two ways! If you need more help setting your tokens see this article –> placeholder
#1. set each time in your session (not recommended in saved/shared scripts!)
Sys.setenv(REDCapSync_TEST = "YoUrNevErShaReToken")
#2. set to your private R sessions!
usethis::edit_r_environ() #finds your file
# Then you add --> REDCapSync_TEST = 'YoUrNevErShaReToken'
# then save file and restart R
# If it worked you will see your token when you run...
Sys.getenv("REDCapSync_TEST")
#And if your project object is setup properly...
project<-load_project("TEST")
view_project_token(project)
Run Core Functions
The following functions represent the core functions of the package.
project <- update_project(project) # update from redcap by checking log and using saved object
project <- add_forms_transformation_to_project(project,forms_tranformation = default_forms_transformation(project))
project <- transform_project(project) # transform to most basic forms, can be modified
project <- drop_redcap_dir(project)
#run shiny app!
run_REDCapSync()
# dev functions not ready for public yet
project <- clean_project(project)
project <- summarize_project(project) #can use for subsets!
project <- summarize_project(project)
project %>% save_summary() # will save summary data, look at the tabs!