mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-09-12 01:49:39 +02:00
113 lines
3.4 KiB
R
113 lines
3.4 KiB
R
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"))
|
|
}
|
|
|
|
## 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)
|
|
|
|
|
|
|
|
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()
|
|
|
|
app_source <- "https://github.com/agdamsbo/freesearcheR"
|
|
gh_issues_page <- "https://github.com/agdamsbo/freesearcheR/issues"
|
|
|
|
header <- tags$span(
|
|
style = "display: flex; align-items: center; justify-content: space-between; margin: 10px 0 10px 0;",
|
|
tags$span("REDCap data evaluation", style = "font-size: 30px;") # ,
|
|
# 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(
|
|
"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:",
|
|
tags$a(href = app_source, target = "_blank", "Source Code"), ", ",
|
|
tags$a(href = gh_issues_page, target = "_blank", "Report Issues")
|
|
)
|
|
|
|
# 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(
|
|
data=tdm_data_read,
|
|
# data = tdm_data_upload,
|
|
# data = tdm_redcap_read,
|
|
filter = filters,
|
|
modules = modules(
|
|
tm_data_table("Data Table"),
|
|
tm_variable_browser_module
|
|
),
|
|
title = build_app_title("REDCap data evaluation"),
|
|
header = header,
|
|
footer = footer
|
|
)
|
|
|
|
shinyApp(app$ui, app$server)
|