OUHSC Statistical Computing User Group
Will Beasley, Dept of Pediatrics,
Biomedical and Behavioral Methodology Core (BBMC)
R doesn't work well when called by a conventional website. RStudio's developers built the Shiny web framework that permits this integration.
(Switch to the slides of screen shots.)
(Switch to the RStudio's Gallery.)
(Switch back to these slides.)
Disclaimer: The following code is a simplication of our real code. The basics are the same, but
channel <- odbcConnect(dsn="BbmcSecurity")
token <- REDCapR::retrieve_token_mssql(
project_name = "Gpav2",
channel = channel
)
uri <- RODBC::sqlQuery(
channel,
"EXEC Security.prcUriStatic @UriName
= 'RedcapBbmc'",
stringsAsFactors=FALSE
)[1, 'Value']
RODBC::odbcClose(channel)
# Pull
dsDC <- REDCapR::redcap_read(
redcap_uri = redcapUri,
token = token,
fields = c("studyid", "dc")
)$data
# Tidy
dsDC <- dplyr::rename_(dsDC,
"study_id" = "studyid",
"dc_responsible" = "dc"
)
ds <- dplyr::left_join(
x = dsSchedule,
y = dsDC,
by = "study_id"
)
pathOut
goes to a write-only directory on the Shiny server, exposed through Samba, so CSVs are saved on the network like a local drive.pathOut <- "//shiny-public/dump/near.csv"
write.csv(ds, file=pathOut, row.names=F)
Helps insulate multiple developers on the same Shiny app.
http://shiny.rstudio.com/gallery/telephones-by-region.html
ui
vs server
worlds
http://shiny.rstudio.com/gallery/datatables-demo.html
DataTables
library is neatly wrapped & exposed through R code.http://shiny.rstudio.com/gallery/reactivity.html