added option to choose var to stratify

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-27 11:55:26 +01:00
parent 6654425554
commit c06d887c24
No known key found for this signature in database
4 changed files with 22 additions and 4 deletions

View file

@ -5,6 +5,6 @@ account: agdamsbo
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 13276335
bundleId: 9412301
bundleId: 9425248
url: https://agdamsbo.shinyapps.io/webResearch/
version: 1

View file

@ -84,6 +84,16 @@ server <- function(input, output, session) {
)
})
output$strat_var <- shiny::renderUI({
selectInput(
inputId = "strat_var",
selected = "none",
label = "Select variable to stratify baseline",
choices = c("none" ,colnames(ds())),
multiple = FALSE
)
})
output$factor_vars <- shiny::renderUI({
selectizeInput(
inputId = "factor_vars",
@ -117,8 +127,8 @@ server <- function(input, output, session) {
data <- data |> factorize(vars = input$factor_vars)
if (is.factor(data[[input$outcome_var]])) {
by.var <- input$outcome_var
if (is.factor(data[[input$strat_var]])) {
by.var <- input$strat_var
} else {
by.var <- NULL
}
@ -149,7 +159,14 @@ server <- function(input, output, session) {
list(
by = by.var
)
),
) |>
(\(.x){
if (!is.null(by.var)){
.x |> gtsummary::add_overall()
} else {
.x
}
})(),
table2 = model |>
regression_table()
)

View file

@ -128,6 +128,7 @@ ui <- bslib::page(
),
shiny::helpText(em("Please specify relevant columns from your data, and press 'Load data'")),
shiny::uiOutput("outcome_var"),
shiny::uiOutput("strat_var"),
shiny::radioButtons(
inputId = "all",
label = "Specify covariables",