mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-09-12 09:59:39 +02:00
114 lines
2.8 KiB
R
114 lines
2.8 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"))
|
||
|
}
|
||
|
|
||
|
data_upload <- teal_data_module(
|
||
|
ui <- function(id) {
|
||
|
ns <- NS(id)
|
||
|
shiny::fluidPage(
|
||
|
shiny::radioButtons(
|
||
|
inputId = "import",
|
||
|
label = "Specify categorical variables?",
|
||
|
selected = "no",
|
||
|
inline = TRUE,
|
||
|
choices = list(
|
||
|
"Upload file" = "file",
|
||
|
"Export from REDCap" = "redcap"
|
||
|
)
|
||
|
),
|
||
|
shiny::conditionalPanel(
|
||
|
condition = "input.import=='file'",
|
||
|
m_datafileUI(id)
|
||
|
),
|
||
|
shiny::conditionalPanel(
|
||
|
condition = "input.import=='redcap'",
|
||
|
m_redcap_readUI(id)
|
||
|
)
|
||
|
)
|
||
|
},
|
||
|
server = function(id) {
|
||
|
ns <- NS(id)
|
||
|
moduleServer(id, function(input, output, session) {
|
||
|
shiny::reactive({
|
||
|
if (input$import == "file") {
|
||
|
m_datafileServer(id, output.format = "teal")
|
||
|
} else {
|
||
|
m_redcap_readServer(id, output.format = "teal")
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
)
|
||
|
|
||
|
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/webresearch"
|
||
|
gh_issues_page <- "https://github.com/agdamsbo/webresearch/issues"
|
||
|
|
||
|
header <- tags$span(
|
||
|
style = "display: flex; align-items: center; justify-content: space-between; margin: 10px 0 10px 0;",
|
||
|
tags$span("webResearch (teal)", 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 teal app was developed by AGDamsbo using the {teal} framework for Shiny apps:",
|
||
|
tags$a(href = app_source, target = "_blank", "Source Code"), ", ",
|
||
|
tags$a(href = gh_issues_page, target = "_blank", "Report Issues")
|
||
|
)
|
||
|
|
||
|
app <- init(
|
||
|
data = data_upload,
|
||
|
filter = filters,
|
||
|
modules = modules(
|
||
|
tm_data_table("Data Table"),
|
||
|
tm_variable_browser_module
|
||
|
),
|
||
|
title = build_app_title("webResearch (teal)"),
|
||
|
header = header,
|
||
|
footer = footer
|
||
|
)
|
||
|
|
||
|
shinyApp(app$ui, app$server)
|