2024-12-04 12:58:55 +01:00
library ( teal )
library ( teal.modules.general )
library ( teal.widgets )
library ( readr )
library ( MASS )
library ( stats )
library ( gtsummary )
library ( gt )
library ( openxlsx2 )
library ( haven )
library ( readODS )
library ( shiny )
library ( bslib )
library ( assertthat )
library ( dplyr )
library ( quarto )
library ( here )
library ( broom )
library ( broom.helpers )
library ( REDCapCAST )
library ( easystats )
library ( patchwork )
library ( DHARMa )
# library(IDEAFilter)
# if (!requireNamespace("webResearch")) {
# devtools::install_github("agdamsbo/webResearch", quiet = TRUE, upgrade = "never")
# }
# library(webResearch)
if ( file.exists ( here :: here ( " functions.R" ) ) ) {
source ( here :: here ( " functions.R" ) )
}
2024-12-09 14:00:44 +01:00
## This setup works for a single possible source
## The UI will work, even with server dependent selection and REDCap exports,
## but when submitting, it only works for the module mentioned first in the server function
## Also most data formatting is lost when passing to a teal_data_object. Bummer!
##
## FRUSTRATION!!
##
## As I read this, two different apps has to be created as things are now: one for upload, one for REDCap.
## https://insightsengineering.github.io/teal/latest-tag/articles/data-as-shiny-module.html#warning
##
##
##
## Ad option to widen data or keep long (new function, would allow easy(ish) MMRM analyses)
2024-12-04 12:58:55 +01:00
tm_variable_browser_module <- tm_variable_browser (
label = " Variable browser" ,
ggplot2_args = ggplot2_args (
labs = list ( subtitle = " Plot generated by Variable Browser Module" )
)
)
filters <- teal :: teal_slices ( )
2024-12-19 15:26:23 +01:00
app_source <- " https://github.com/agdamsbo/freesearcheR"
gh_issues_page <- " https://github.com/agdamsbo/freesearcheR/issues"
2024-12-04 12:58:55 +01:00
header <- tags $ span (
style = " display: flex; align-items: center; justify-content: space-between; margin: 10px 0 10px 0;" ,
2024-12-09 14:00:44 +01:00
tags $ span ( " REDCap data evaluation" , style = " font-size: 30px;" ) # ,
2024-12-04 12:58:55 +01:00
# tags$span(
# style = "display: flex; align-items: center;",
# tags$img(src = nest_logo, alt = "NEST logo", height = "45px", style = "margin-right:10px;"),
# tags$span(style = "font-size: 24px;", "agdamsbo")
# )
)
footer <- tags $ p (
2024-12-09 14:00:44 +01:00
" This is a simple, app for REDCap-based data browsing and evaluation. Data is only stored temporarily and deleted when the browser is refreshed or closed. The app was developed by AGDamsbo using the {teal} framework for building Shiny apps:" ,
2024-12-04 12:58:55 +01:00
tags $ a ( href = app_source , target = " _blank" , " Source Code" ) , " , " ,
tags $ a ( href = gh_issues_page , target = " _blank" , " Report Issues" )
)
2024-12-09 14:00:44 +01:00
# teal_init <- function(data = tdm_redcap_read,
# filter = filters,
# modules = teal::modules(
# teal.modules.general::tm_data_table("Data Table"),
# tm_variable_browser_module
# ),
# title = teal::build_app_title("REDCap browser (teal)"),
# header = header,
# footer = footer, ...) {
# teal::init(data,
# filter,
# modules,
# title,
# header,
# footer,
# ...
# )
# }
#
# redcap_browser_app <- teal_init(data = tdm_data_upload)
app <- teal :: init (
2025-01-15 16:21:38 +01:00
data = tdm_data_read ,
2024-12-13 13:37:19 +01:00
# data = tdm_data_upload,
2025-01-15 16:21:38 +01:00
# data = tdm_redcap_read,
2024-12-04 12:58:55 +01:00
filter = filters ,
modules = modules (
tm_data_table ( " Data Table" ) ,
tm_variable_browser_module
) ,
2024-12-09 14:00:44 +01:00
title = build_app_title ( " REDCap data evaluation" ) ,
2024-12-04 12:58:55 +01:00
header = header ,
footer = footer
)
shinyApp ( app $ ui , app $ server )