Skip to contents

Setup

This is how you get REDCap turned into an R database…

library("RosyREDCap")

projects <- get_projects() # get list of cached projects

View(projects) # show your previously saved projects

DB <- setup_DB(
  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 three 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(RosyREDCap_token_TEST = "YoUrNevErShaReToken")

#2. set to your private R sessions!
usethis::edit_r_environ() #finds your file
# Then you add --> RosyREDCap_token_TEST = 'YoUrNevErShaReToken'
# then save file and restart R

# If it worked you will see your token when you run...
Sys.getenv("RosyREDCap_token_TEST")
#And if your DB object is setup properly...
#3. Using the REDCap console
DB<-load_DB("TEST")
set_REDCap_token(DB)
# can see if it's set correctly
view_REDCap_token(DB)

Run Core Functions

The following functions represent the core functions of the package.


DB <- update_DB(DB) # update from redcap by checking log and using saved object 

DB <- add_forms_transformation_to_DB(DB,forms_tranformation = default_forms_transformation(DB))

DB <- transform_DB(DB) # transform to most basic forms, can be modified

DB <- drop_redcap_dir(DB)

#run shiny app!
run_RosyREDCap()

# dev functions not ready for public yet
DB <- clean_DB(DB)
DB <- summarize_DB(DB) #can use for subsets!
DB <- summarize_DB(DB)
DB %>% save_summary() # will save summary data, look at the tabs!

Explore Outputs!


DB$metadata %>% add_list_to_global()

DB$data %>% add_list_to_global()

#DB$summary %>% add_list_to_global() #not ready for public

listviewer::jsonedit(DB) # view object