diff --git a/CITATION.cff b/CITATION.cff index b2741aa4..f026dade 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -9,7 +9,7 @@ type: software license: AGPL-3.0-or-later title: 'FreesearchR: A free and open-source browser based data analysis tool for researchers with publication ready output' -version: 25.5.5 +version: 25.5.4 doi: 10.5281/zenodo.14527429 identifiers: - type: url @@ -990,18 +990,6 @@ references: orcid: https://orcid.org/0000-0002-5645-3493 year: '2025' doi: 10.32614/CRAN.package.shinyjs -- type: software - title: emmeans - abstract: 'emmeans: Estimated Marginal Means, aka Least-Squares Means' - notes: Imports - url: https://rvlenth.github.io/emmeans/ - repository: https://CRAN.R-project.org/package=emmeans - authors: - - family-names: Lenth - given-names: Russell V. - email: russell-lenth@uiowa.edu - year: '2025' - doi: 10.32614/CRAN.package.emmeans - type: software title: styler abstract: 'styler: Non-Invasive Pretty Printing of R Code' diff --git a/DESCRIPTION b/DESCRIPTION index f245494a..5a9123e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: FreesearchR Title: A free and open-source browser based data analysis tool for researchers with publication ready output -Version: 25.5.5 +Version: 25.5.4 Authors@R: c( person("Andreas Gammelgaard", "Damsbo",email="agdamsbo@clin.au.dk", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7559-1154")), @@ -63,8 +63,7 @@ Imports: ggforce, RcppArmadillo, ggcorrplot, - shinyjs, - emmeans + shinyjs Suggests: styler, devtools, diff --git a/NEWS.md b/NEWS.md index 44b78379..2cd0e65b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,8 +2,6 @@ - *FIX* several minor bugs and polish -- *FIX* include/exclude p-values in regression table. - # FreesearchR 25.5.4 - *FIX* correctly omit NAs in `data_type()` call diff --git a/R/app_version.R b/R/app_version.R index d4d8dc13..5e843a23 100644 --- a/R/app_version.R +++ b/R/app_version.R @@ -1 +1 @@ -app_version <- function()'25.5.5' +app_version <- function()'25.5.4' diff --git a/R/hosted_version.R b/R/hosted_version.R index 3cd23688..a898784a 100644 --- a/R/hosted_version.R +++ b/R/hosted_version.R @@ -1 +1 @@ -hosted_version <- function()'v25.5.5-250514' +hosted_version <- function()'v25.5.4-250513' diff --git a/R/regression-module.R b/R/regression-module.R index ee2eb9f0..f79c0c50 100644 --- a/R/regression-module.R +++ b/R/regression-module.R @@ -322,7 +322,7 @@ regression_server <- function(id, ############################################################################## ######### - ######### Regression models + ######### Regression analysis ######### ############################################################################## @@ -370,179 +370,6 @@ regression_server <- function(id, } ) - - - shiny::observeEvent( - list( - data_r(), - regression_vars() - ), - { - rv$list$regression$tables <- NULL - } - ) - - ############################################################################## - ######### - ######### Regression table - ######### - ############################################################################## - - ### Creating the regression table - shiny::observeEvent( - input$load, - { - shiny::req(rv$list$regression$models) - ## To avoid plotting old models on fail/error - rv$list$regression$tables <- NULL - - # browser() - tryCatch( - { - parameters <- list( - p.values = input$add_regression_p == "no" - ) - - out <- lapply(rv$list$regression$models, \(.x){ - .x$model - }) |> - purrr::map(\(.x){ - do.call( - regression_table, - append_list(.x, parameters, "x") - ) - }) - - rv$list$regression$models |> - purrr::imap(\(.x, .i){ - rv$list$regression$models[[.i]][["code_table"]] <- paste( - .x$code, - expression_string(rlang::call2(.fn = "regression_table", !!!parameters, .ns = "FreesearchR"), assign.str = NULL), - sep = "|>\n" - ) - }) - - rv$list$regression$tables <- out - rv$list$input <- input - }, - warning = function(warn) { - showNotification(paste0(warn), type = "warning") - }, - error = function(err) { - showNotification(paste0("Creating a regression table failed with the following error: ", err), type = "err") - } - ) - } - ) - - ## Consider creating merged table with theming and then passing object - ## to render. - - output$table2 <- gt::render_gt({ - ## Print checks if a regression table is present - if (!is.null(rv$list$regression$tables)) { - # gtsummary::theme_gtsummary_journal(journal = "jama") - merged <- rv$list$regression$tables |> - tbl_merge() - - if (input$add_regression_p == "no") { - merged <- merged |> - gtsummary::modify_column_hide(column = dplyr::starts_with("p.value")) - } - - out <- merged |> - gtsummary::as_gt() |> - gt::tab_header(gt::md(glue::glue("**Table 2: {rv$list$regression$params$descr}**"))) - - # rv$list$regression$table_merged <- out - - out - } else { - return(NULL) - } - }) - - ############################################################################## - ######### - ######### Coefficients plot - ######### - ############################################################################## - - shiny::observeEvent(list( - input$plot_model, - rv$list$regression - ), { - shiny::req(input$plot_model) - - tryCatch( - { - p <- merge_long( - rv$list$regression, - sort_by( - input$plot_model, - c("Univariable", "Minimal", "Multivariable"), - na.rm = TRUE - ) - ) |> - (\(.x){ - if (length(input$plot_model) > 1) { - plot.tbl_regression( - x = .x, - colour = "model", - dodged = TRUE - ) + - ggplot2::theme(legend.position = "bottom") + - ggplot2::guides(color = ggplot2::guide_legend(reverse = TRUE)) - } else { - plot.tbl_regression( - x = .x, - colour = "variable" - ) + - ggplot2::theme(legend.position = "none") - } - })() - - rv$plot <- p + - ggplot2::scale_y_discrete(labels = scales::label_wrap(15)) + - gg_theme_shiny() - }, - error = function(err) { - showNotification(paste0(err), type = "err") - } - ) - }) - - - output$regression_plot <- shiny::renderPlot( - { - shiny::req(input$plot_model) - - rv$plot - }, - alt = "Regression coefficient plot" - ) - - # plot_download_server( - # id = ns("reg_plot_download"), - # data = shiny::reactive(rv$plot) - # ) - - output$download_plot <- shiny::downloadHandler( - filename = paste0("regression_plot.", input$plot_type), - content = function(file) { - shiny::withProgress(message = "Saving the plot. Hold on for a moment..", { - ggplot2::ggsave( - filename = file, - plot = rv$plot, - width = input$plot_width, - height = input$plot_height, - dpi = 300, - units = "mm", scale = 2 - ) - }) - } - ) - ############################################################################## ######### ######### Model checks @@ -650,6 +477,171 @@ regression_server <- function(id, alt = "Assumptions testing of the multivariable regression model" ) + shiny::observeEvent( + list( + data_r(), + regression_vars() + ), + { + rv$list$regression$tables <- NULL + } + ) + + ### Creating the regression table + shiny::observeEvent( + input$load, + { + shiny::req(rv$list$regression$models) + ## To avoid plotting old models on fail/error + rv$list$regression$tables <- NULL + + # browser() + tryCatch( + { + parameters <- list( + p.values = input$add_regression_p == "no" + ) + + out <- lapply(rv$list$regression$models, \(.x){ + .x$model + }) |> + purrr::map(\(.x){ + do.call( + regression_table, + append_list(.x, parameters, "x") + ) + }) + + rv$list$regression$models |> + purrr::imap(\(.x, .i){ + rv$list$regression$models[[.i]][["code_table"]] <- paste( + .x$code, + expression_string(rlang::call2(.fn = "regression_table", !!!parameters, .ns = "FreesearchR"), assign.str = NULL), + sep = "|>\n" + ) + }) + + rv$list$regression$tables <- out + rv$list$input <- input + }, + warning = function(warn) { + showNotification(paste0(warn), type = "warning") + }, + error = function(err) { + showNotification(paste0("Creating a regression table failed with the following error: ", err), type = "err") + } + ) + } + ) + + ## Consider creating merged table with theming and then passing object + ## to render. + + output$table2 <- gt::render_gt({ + ## Print checks if a regression table is present + if (!is.null(rv$list$regression$tables)) { + gtsummary::theme_gtsummary_journal(journal = "jama") + merged <- rv$list$regression$tables |> + tbl_merge() + + if (input$add_regression_p == "no") { + merged <- merged |> + gtsummary::modify_column_hide(column = dplyr::starts_with("p.value")) + } + + out <- merged |> + gtsummary::as_gt() |> + gt::tab_header(gt::md(glue::glue("**Table 2: {rv$list$regression$params$descr}**"))) + + rv$list$regression$table_merged + + out + } else { + return(NULL) + } + }) + + ############################################################################## + ######### + ######### Coefficients plot + ######### + ############################################################################## + + shiny::observeEvent(list( + input$plot_model, + rv$list$regression + ), { + shiny::req(input$plot_model) + + tryCatch( + { + p <- merge_long( + rv$list$regression, + sort_by( + input$plot_model, + c("Univariable", "Minimal", "Multivariable"), + na.rm = TRUE + ) + ) |> + (\(.x){ + if (length(input$plot_model) > 1) { + plot.tbl_regression( + x = .x, + colour = "model", + dodged = TRUE + ) + + ggplot2::theme(legend.position = "bottom") + + ggplot2::guides(color = ggplot2::guide_legend(reverse = TRUE)) + } else { + plot.tbl_regression( + x = .x, + colour = "variable" + ) + + ggplot2::theme(legend.position = "none") + } + })() + + rv$plot <- p + + ggplot2::scale_y_discrete(labels = scales::label_wrap(15)) + + gg_theme_shiny() + }, + error = function(err) { + showNotification(paste0(err), type = "err") + } + ) + }) + + + output$regression_plot <- shiny::renderPlot( + { + shiny::req(input$plot_model) + + rv$plot + }, + alt = "Regression coefficient plot" + ) + + # plot_download_server( + # id = ns("reg_plot_download"), + # data = shiny::reactive(rv$plot) + # ) + + output$download_plot <- shiny::downloadHandler( + filename = paste0("regression_plot.", input$plot_type), + content = function(file) { + shiny::withProgress(message = "Saving the plot. Hold on for a moment..", { + ggplot2::ggsave( + filename = file, + plot = rv$plot, + width = input$plot_width, + height = input$plot_height, + dpi = 300, + units = "mm", scale = 2 + ) + }) + } + ) + ############################################################################## ######### ######### Output diff --git a/R/regression_table.R b/R/regression_table.R index 557359b3..b0331c72 100644 --- a/R/regression_table.R +++ b/R/regression_table.R @@ -140,7 +140,7 @@ regression_table_create <- function(x, ..., args.list = NULL, fun = "gtsummary:: } } - gtsummary::theme_gtsummary_journal(journal = theme) + # gtsummary::theme_gtsummary_journal(journal = theme) if (inherits(x, "polr")) { # browser() out <- do.call(getfun(fun), c(list(x = x), args.list)) diff --git a/R/sysdata.rda b/R/sysdata.rda index 3bc008a0..080cfc43 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/SESSION.md b/SESSION.md index 9dd0b555..dc20f495 100644 --- a/SESSION.md +++ b/SESSION.md @@ -11,213 +11,177 @@ |collate |en_US.UTF-8 | |ctype |en_US.UTF-8 | |tz |Europe/Copenhagen | -|date |2025-05-14 | +|date |2025-05-10 | |rstudio |2024.12.1+563 Kousa Dogwood (desktop) | |pandoc |3.6.4 @ /opt/homebrew/bin/ (via rmarkdown) | |quarto |1.7.30 @ /usr/local/bin/quarto | -|FreesearchR |25.5.5.250514 | +|FreesearchR |25.5.4.250510 | -------------------------------------------------------------------------------- ----------------------------------- packages ----------------------------------- -------------------------------------------------------------------------------- -|package |loadedversion |date |source | -|:-----------------|:-------------|:----------|:--------------| -|apexcharter |0.4.4 |2024-09-06 |CRAN (R 4.4.1) | -|askpass |1.2.1 |2024-10-04 |CRAN (R 4.4.1) | -|assertthat |0.2.1 |2019-03-21 |CRAN (R 4.4.1) | -|backports |1.5.0 |2024-05-23 |CRAN (R 4.4.1) | -|base64enc |0.1-3 |2015-07-28 |CRAN (R 4.4.1) | -|bayestestR |0.15.3 |2025-04-28 |CRAN (R 4.4.1) | -|bit |4.6.0 |2025-03-06 |CRAN (R 4.4.1) | -|bit64 |4.6.0-1 |2025-01-16 |CRAN (R 4.4.1) | -|bitops |1.0-9 |2024-10-03 |CRAN (R 4.4.1) | -|boot |1.3-31 |2024-08-28 |CRAN (R 4.4.1) | -|brio |1.1.5 |2024-04-24 |CRAN (R 4.4.1) | -|broom |1.0.8 |2025-03-28 |CRAN (R 4.4.1) | -|broom.helpers |1.21.0 |2025-04-24 |CRAN (R 4.4.1) | -|bsicons |0.1.2 |2023-11-04 |CRAN (R 4.4.0) | -|bslib |0.9.0 |2025-01-30 |CRAN (R 4.4.1) | -|cachem |1.1.0 |2024-05-16 |CRAN (R 4.4.1) | -|cards |0.6.0 |2025-04-11 |CRAN (R 4.4.1) | -|cardx |0.2.4 |2025-04-12 |CRAN (R 4.4.1) | -|caTools |1.18.3 |2024-09-04 |CRAN (R 4.4.1) | -|cellranger |1.1.0 |2016-07-27 |CRAN (R 4.4.0) | -|cffr |1.2.0 |2025-01-25 |CRAN (R 4.4.1) | -|checkmate |2.3.2 |2024-07-29 |CRAN (R 4.4.0) | -|class |7.3-23 |2025-01-01 |CRAN (R 4.4.1) | -|classInt |0.4-11 |2025-01-08 |CRAN (R 4.4.1) | -|cli |3.6.5 |2025-04-23 |CRAN (R 4.4.1) | -|cluster |2.1.8.1 |2025-03-12 |CRAN (R 4.4.1) | -|codetools |0.2-20 |2024-03-31 |CRAN (R 4.4.1) | -|colorspace |2.1-1 |2024-07-26 |CRAN (R 4.4.1) | -|commonmark |1.9.5 |2025-03-17 |CRAN (R 4.4.1) | -|crayon |1.5.3 |2024-06-20 |CRAN (R 4.4.1) | -|curl |6.2.2 |2025-03-24 |CRAN (R 4.4.1) | -|data.table |1.17.0 |2025-02-22 |CRAN (R 4.4.1) | -|datamods |1.5.3 |2024-10-02 |CRAN (R 4.4.1) | -|datawizard |1.0.2 |2025-03-24 |CRAN (R 4.4.1) | -|DEoptimR |1.1-3-1 |2024-11-23 |CRAN (R 4.4.1) | -|desc |1.4.3 |2023-12-10 |CRAN (R 4.4.1) | -|devtools |2.4.5 |2022-10-11 |CRAN (R 4.4.0) | -|DHARMa |0.4.7 |2024-10-18 |CRAN (R 4.4.1) | -|digest |0.6.37 |2024-08-19 |CRAN (R 4.4.1) | -|doParallel |1.0.17 |2022-02-07 |CRAN (R 4.4.0) | -|dplyr |1.1.4 |2023-11-17 |CRAN (R 4.4.0) | -|DT |0.33 |2024-04-04 |CRAN (R 4.4.0) | -|e1071 |1.7-16 |2024-09-16 |CRAN (R 4.4.1) | -|easystats |0.7.4 |2025-02-06 |CRAN (R 4.4.1) | -|ellipsis |0.3.2 |2021-04-29 |CRAN (R 4.4.1) | -|emmeans |1.11.1 |2025-05-04 |CRAN (R 4.4.1) | -|esquisse |2.1.0 |2025-02-21 |CRAN (R 4.4.1) | -|estimability |1.5.1 |2024-05-12 |CRAN (R 4.4.0) | -|eulerr |7.0.2 |2024-03-28 |CRAN (R 4.4.0) | -|evaluate |1.0.3 |2025-01-10 |CRAN (R 4.4.1) | -|farver |2.1.2 |2024-05-13 |CRAN (R 4.4.1) | -|fastmap |1.2.0 |2024-05-15 |CRAN (R 4.4.1) | -|flextable |0.9.7 |2024-10-27 |CRAN (R 4.4.1) | -|fontawesome |0.5.3 |2024-11-16 |CRAN (R 4.4.1) | -|fontBitstreamVera |0.1.1 |2017-02-01 |CRAN (R 4.4.1) | -|fontLiberation |0.1.0 |2016-10-15 |CRAN (R 4.4.1) | -|fontquiver |0.2.1 |2017-02-01 |CRAN (R 4.4.0) | -|forcats |1.0.0 |2023-01-29 |CRAN (R 4.4.0) | -|foreach |1.5.2 |2022-02-02 |CRAN (R 4.4.0) | -|foreign |0.8-90 |2025-03-31 |CRAN (R 4.4.1) | -|Formula |1.2-5 |2023-02-24 |CRAN (R 4.4.1) | -|FreesearchR |25.5.5 |NA |NA | -|fs |1.6.6 |2025-04-12 |CRAN (R 4.4.1) | -|gdtools |0.4.2 |2025-03-27 |CRAN (R 4.4.1) | -|generics |0.1.3 |2022-07-05 |CRAN (R 4.4.1) | -|ggalluvial |0.12.5 |2023-02-22 |CRAN (R 4.4.0) | -|ggcorrplot |0.1.4.1 |2023-09-05 |CRAN (R 4.4.0) | -|ggforce |0.4.2 |2024-02-19 |CRAN (R 4.4.0) | -|ggplot2 |3.5.2 |2025-04-09 |CRAN (R 4.4.1) | -|ggridges |0.5.6 |2024-01-23 |CRAN (R 4.4.0) | -|ggstats |0.9.0 |2025-03-10 |CRAN (R 4.4.1) | -|glue |1.8.0 |2024-09-30 |CRAN (R 4.4.1) | -|gridExtra |2.3 |2017-09-09 |CRAN (R 4.4.1) | -|gt |1.0.0 |2025-04-05 |CRAN (R 4.4.1) | -|gtable |0.3.6 |2024-10-25 |CRAN (R 4.4.1) | -|gtsummary |2.2.0 |2025-04-14 |CRAN (R 4.4.1) | -|haven |2.5.4 |2023-11-30 |CRAN (R 4.4.0) | -|here |1.0.1 |2020-12-13 |CRAN (R 4.4.1) | -|Hmisc |5.2-3 |2025-03-16 |CRAN (R 4.4.1) | -|hms |1.1.3 |2023-03-21 |CRAN (R 4.4.0) | -|htmlTable |2.4.3 |2024-07-21 |CRAN (R 4.4.0) | -|htmltools |0.5.8.1 |2024-04-04 |CRAN (R 4.4.1) | -|htmlwidgets |1.6.4 |2023-12-06 |CRAN (R 4.4.0) | -|httpuv |1.6.16 |2025-04-16 |CRAN (R 4.4.1) | -|IDEAFilter |0.2.0 |2024-04-15 |CRAN (R 4.4.0) | -|insight |1.2.0 |2025-04-22 |CRAN (R 4.4.1) | -|iterators |1.0.14 |2022-02-05 |CRAN (R 4.4.1) | -|jquerylib |0.1.4 |2021-04-26 |CRAN (R 4.4.0) | -|jsonlite |2.0.0 |2025-03-27 |CRAN (R 4.4.1) | -|jsonvalidate |1.5.0 |2025-02-07 |CRAN (R 4.4.1) | -|KernSmooth |2.23-26 |2025-01-01 |CRAN (R 4.4.1) | -|keyring |1.3.2 |2023-12-11 |CRAN (R 4.4.0) | -|knitr |1.50 |2025-03-16 |CRAN (R 4.4.1) | -|later |1.4.2 |2025-04-08 |CRAN (R 4.4.1) | -|lattice |0.22-7 |2025-04-02 |CRAN (R 4.4.1) | -|lifecycle |1.0.4 |2023-11-07 |CRAN (R 4.4.1) | -|lme4 |1.1-37 |2025-03-26 |CRAN (R 4.4.1) | -|lubridate |1.9.4 |2024-12-08 |CRAN (R 4.4.1) | -|magrittr |2.0.3 |2022-03-30 |CRAN (R 4.4.1) | -|MASS |7.3-65 |2025-02-28 |CRAN (R 4.4.1) | -|Matrix |1.7-3 |2025-03-11 |CRAN (R 4.4.1) | -|memoise |2.0.1 |2021-11-26 |CRAN (R 4.4.0) | -|mime |0.13 |2025-03-17 |CRAN (R 4.4.1) | -|miniUI |0.1.2 |2025-04-17 |CRAN (R 4.4.1) | -|minqa |1.2.8 |2024-08-17 |CRAN (R 4.4.1) | -|mvtnorm |1.3-3 |2025-01-10 |CRAN (R 4.4.1) | -|nlme |3.1-168 |2025-03-31 |CRAN (R 4.4.1) | -|nloptr |2.2.1 |2025-03-17 |CRAN (R 4.4.1) | -|nnet |7.3-20 |2025-01-01 |CRAN (R 4.4.1) | -|officer |0.6.8 |2025-03-23 |CRAN (R 4.4.1) | -|opdisDownsampling |1.0.1 |2024-04-15 |CRAN (R 4.4.0) | -|openssl |2.3.2 |2025-02-03 |CRAN (R 4.4.1) | -|openxlsx2 |1.15 |2025-04-25 |CRAN (R 4.4.1) | -|parameters |0.24.2 |2025-03-04 |CRAN (R 4.4.1) | -|patchwork |1.3.0 |2024-09-16 |CRAN (R 4.4.1) | -|pbmcapply |1.5.1 |2022-04-28 |CRAN (R 4.4.1) | -|performance |0.13.0 |2025-01-15 |CRAN (R 4.4.1) | -|phosphoricons |0.2.1 |2024-04-08 |CRAN (R 4.4.0) | -|pillar |1.10.2 |2025-04-05 |CRAN (R 4.4.1) | -|pkgbuild |1.4.7 |2025-03-24 |CRAN (R 4.4.1) | -|pkgconfig |2.0.3 |2019-09-22 |CRAN (R 4.4.1) | -|pkgload |1.4.0 |2024-06-28 |CRAN (R 4.4.0) | -|plyr |1.8.9 |2023-10-02 |CRAN (R 4.4.1) | -|polyclip |1.10-7 |2024-07-23 |CRAN (R 4.4.1) | -|pracma |2.4.4 |2023-11-10 |CRAN (R 4.4.1) | -|processx |3.8.6 |2025-02-21 |CRAN (R 4.4.1) | -|profvis |0.4.0 |2024-09-20 |CRAN (R 4.4.1) | -|promises |1.3.2 |2024-11-28 |CRAN (R 4.4.1) | -|proxy |0.4-27 |2022-06-09 |CRAN (R 4.4.1) | -|ps |1.9.1 |2025-04-12 |CRAN (R 4.4.1) | -|purrr |1.0.4 |2025-02-05 |CRAN (R 4.4.1) | -|qqconf |1.3.2 |2023-04-14 |CRAN (R 4.4.0) | -|qqplotr |0.0.6 |2023-01-25 |CRAN (R 4.4.0) | -|quarto |1.4.4 |2024-07-20 |CRAN (R 4.4.0) | -|R6 |2.6.1 |2025-02-15 |CRAN (R 4.4.1) | -|ragg |1.4.0 |2025-04-10 |CRAN (R 4.4.1) | -|rankinPlot |1.1.0 |2023-01-30 |CRAN (R 4.4.0) | -|rbibutils |2.3 |2024-10-04 |CRAN (R 4.4.1) | -|RColorBrewer |1.1-3 |2022-04-03 |CRAN (R 4.4.1) | -|Rcpp |1.0.14 |2025-01-12 |CRAN (R 4.4.1) | -|RcppArmadillo |14.4.2-1 |2025-04-25 |CRAN (R 4.4.1) | -|Rdpack |2.6.4 |2025-04-09 |CRAN (R 4.4.1) | -|reactable |0.4.4 |2023-03-12 |CRAN (R 4.4.0) | -|readODS |2.3.2 |2025-01-13 |CRAN (R 4.4.1) | -|readr |2.1.5 |2024-01-10 |CRAN (R 4.4.0) | -|readxl |1.4.5 |2025-03-07 |CRAN (R 4.4.1) | -|REDCapCAST |25.3.2 |2025-03-10 |CRAN (R 4.4.1) | -|REDCapR |1.4.0 |2025-01-11 |CRAN (R 4.4.1) | -|reformulas |0.4.0 |2024-11-03 |CRAN (R 4.4.1) | -|remotes |2.5.0 |2024-03-17 |CRAN (R 4.4.1) | -|rempsyc |0.1.9 |2025-02-01 |CRAN (R 4.4.1) | -|renv |1.1.4 |2025-03-20 |CRAN (R 4.4.1) | -|reshape2 |1.4.4 |2020-04-09 |CRAN (R 4.4.0) | -|rio |1.2.3 |2024-09-25 |CRAN (R 4.4.1) | -|rlang |1.1.6 |2025-04-11 |CRAN (R 4.4.1) | -|rmarkdown |2.29 |2024-11-04 |CRAN (R 4.4.1) | -|robustbase |0.99-4-1 |2024-09-27 |CRAN (R 4.4.1) | -|roxygen2 |7.3.2 |2024-06-28 |CRAN (R 4.4.0) | -|rpart |4.1.24 |2025-01-07 |CRAN (R 4.4.1) | -|rprojroot |2.0.4 |2023-11-05 |CRAN (R 4.4.1) | -|rsconnect |1.3.4 |2025-01-22 |CRAN (R 4.4.1) | -|rstudioapi |0.17.1 |2024-10-22 |CRAN (R 4.4.1) | -|sass |0.4.10 |2025-04-11 |CRAN (R 4.4.1) | -|scales |1.4.0 |2025-04-24 |CRAN (R 4.4.1) | -|see |0.11.0 |2025-03-11 |CRAN (R 4.4.1) | -|sessioninfo |1.2.3 |2025-02-05 |CRAN (R 4.4.1) | -|shiny |1.10.0 |2024-12-14 |CRAN (R 4.4.1) | -|shinybusy |0.3.3 |2024-03-09 |CRAN (R 4.4.0) | -|shinyjs |2.1.0 |2021-12-23 |CRAN (R 4.4.0) | -|shinyTime |1.0.3 |2022-08-19 |CRAN (R 4.4.0) | -|shinyWidgets |0.9.0 |2025-02-21 |CRAN (R 4.4.1) | -|stringi |1.8.7 |2025-03-27 |CRAN (R 4.4.1) | -|stringr |1.5.1 |2023-11-14 |CRAN (R 4.4.0) | -|systemfonts |1.2.2 |2025-04-04 |CRAN (R 4.4.1) | -|testthat |3.2.3 |2025-01-13 |CRAN (R 4.4.1) | -|textshaping |1.0.0 |2025-01-20 |CRAN (R 4.4.1) | -|thematic |0.1.6 |2024-07-29 |CRAN (R 4.4.0) | -|tibble |3.2.1 |2023-03-20 |CRAN (R 4.4.0) | -|tidyr |1.3.1 |2024-01-24 |CRAN (R 4.4.1) | -|tidyselect |1.2.1 |2024-03-11 |CRAN (R 4.4.0) | -|timechange |0.3.0 |2024-01-18 |CRAN (R 4.4.1) | -|toastui |0.4.0 |2025-04-03 |CRAN (R 4.4.1) | -|tweenr |2.0.3 |2024-02-26 |CRAN (R 4.4.0) | -|twosamples |2.0.1 |2023-06-23 |CRAN (R 4.4.1) | -|tzdb |0.5.0 |2025-03-15 |CRAN (R 4.4.1) | -|urlchecker |1.0.1 |2021-11-30 |CRAN (R 4.4.1) | -|usethis |3.1.0 |2024-11-26 |CRAN (R 4.4.1) | -|uuid |1.2-1 |2024-07-29 |CRAN (R 4.4.1) | -|V8 |6.0.3 |2025-03-26 |CRAN (R 4.4.1) | -|vctrs |0.6.5 |2023-12-01 |CRAN (R 4.4.0) | -|vroom |1.6.5 |2023-12-05 |CRAN (R 4.4.0) | -|withr |3.0.2 |2024-10-28 |CRAN (R 4.4.1) | -|writexl |1.5.4 |2025-04-15 |CRAN (R 4.4.1) | -|xfun |0.52 |2025-04-02 |CRAN (R 4.4.1) | -|xml2 |1.3.8 |2025-03-14 |CRAN (R 4.4.1) | -|xtable |1.8-4 |2019-04-21 |CRAN (R 4.4.1) | -|yaml |2.3.10 |2024-07-26 |CRAN (R 4.4.1) | -|zip |2.3.2 |2025-02-01 |CRAN (R 4.4.1) | +|package |loadedversion |date |source | +|:-------------|:-------------|:----------|:--------------| +|apexcharter |0.4.4 |2024-09-06 |CRAN (R 4.4.1) | +|askpass |1.2.1 |2024-10-04 |CRAN (R 4.4.1) | +|assertthat |0.2.1 |2019-03-21 |CRAN (R 4.4.1) | +|backports |1.5.0 |2024-05-23 |CRAN (R 4.4.1) | +|bayestestR |0.15.3 |2025-04-28 |CRAN (R 4.4.1) | +|bit |4.6.0 |2025-03-06 |CRAN (R 4.4.1) | +|bit64 |4.6.0-1 |2025-01-16 |CRAN (R 4.4.1) | +|boot |1.3-31 |2024-08-28 |CRAN (R 4.4.1) | +|broom |1.0.8 |2025-03-28 |CRAN (R 4.4.1) | +|broom.helpers |1.21.0 |2025-04-24 |CRAN (R 4.4.1) | +|bsicons |0.1.2 |2023-11-04 |CRAN (R 4.4.0) | +|bslib |0.9.0 |2025-01-30 |CRAN (R 4.4.1) | +|cachem |1.1.0 |2024-05-16 |CRAN (R 4.4.1) | +|cellranger |1.1.0 |2016-07-27 |CRAN (R 4.4.0) | +|cffr |1.2.0 |2025-01-25 |CRAN (R 4.4.1) | +|class |7.3-23 |2025-01-01 |CRAN (R 4.4.1) | +|classInt |0.4-11 |2025-01-08 |CRAN (R 4.4.1) | +|cli |3.6.5 |2025-04-23 |CRAN (R 4.4.1) | +|commonmark |1.9.5 |2025-03-17 |CRAN (R 4.4.1) | +|correlation |0.8.7 |2025-03-03 |CRAN (R 4.4.1) | +|crayon |1.5.3 |2024-06-20 |CRAN (R 4.4.1) | +|curl |6.2.2 |2025-03-24 |CRAN (R 4.4.1) | +|data.table |1.17.0 |2025-02-22 |CRAN (R 4.4.1) | +|datamods |1.5.3 |2024-10-02 |CRAN (R 4.4.1) | +|datawizard |1.0.2 |2025-03-24 |CRAN (R 4.4.1) | +|desc |1.4.3 |2023-12-10 |CRAN (R 4.4.1) | +|devtools |2.4.5 |2022-10-11 |CRAN (R 4.4.0) | +|DHARMa |0.4.7 |2024-10-18 |CRAN (R 4.4.1) | +|digest |0.6.37 |2024-08-19 |CRAN (R 4.4.1) | +|dplyr |1.1.4 |2023-11-17 |CRAN (R 4.4.0) | +|DT |0.33 |2024-04-04 |CRAN (R 4.4.0) | +|e1071 |1.7-16 |2024-09-16 |CRAN (R 4.4.1) | +|easystats |0.7.4 |2025-02-06 |CRAN (R 4.4.1) | +|effectsize |1.0.0 |2024-12-10 |CRAN (R 4.4.1) | +|ellipsis |0.3.2 |2021-04-29 |CRAN (R 4.4.1) | +|eulerr |7.0.2 |2024-03-28 |CRAN (R 4.4.0) | +|evaluate |1.0.3 |2025-01-10 |CRAN (R 4.4.1) | +|farver |2.1.2 |2024-05-13 |CRAN (R 4.4.1) | +|fastmap |1.2.0 |2024-05-15 |CRAN (R 4.4.1) | +|fontawesome |0.5.3 |2024-11-16 |CRAN (R 4.4.1) | +|forcats |1.0.0 |2023-01-29 |CRAN (R 4.4.0) | +|fs |1.6.6 |2025-04-12 |CRAN (R 4.4.1) | +|generics |0.1.3 |2022-07-05 |CRAN (R 4.4.1) | +|ggalluvial |0.12.5 |2023-02-22 |CRAN (R 4.4.0) | +|ggforce |0.4.2 |2024-02-19 |CRAN (R 4.4.0) | +|ggplot2 |3.5.2 |2025-04-09 |CRAN (R 4.4.1) | +|glue |1.8.0 |2024-09-30 |CRAN (R 4.4.1) | +|gridExtra |2.3 |2017-09-09 |CRAN (R 4.4.1) | +|gt |1.0.0 |2025-04-05 |CRAN (R 4.4.1) | +|gtable |0.3.6 |2024-10-25 |CRAN (R 4.4.1) | +|gtsummary |2.2.0 |2025-04-14 |CRAN (R 4.4.1) | +|haven |2.5.4 |2023-11-30 |CRAN (R 4.4.0) | +|here |1.0.1 |2020-12-13 |CRAN (R 4.4.1) | +|hms |1.1.3 |2023-03-21 |CRAN (R 4.4.0) | +|htmltools |0.5.8.1 |2024-04-04 |CRAN (R 4.4.1) | +|htmlwidgets |1.6.4 |2023-12-06 |CRAN (R 4.4.0) | +|httpuv |1.6.16 |2025-04-16 |CRAN (R 4.4.1) | +|IDEAFilter |0.2.0 |2024-04-15 |CRAN (R 4.4.0) | +|insight |1.2.0 |2025-04-22 |CRAN (R 4.4.1) | +|jquerylib |0.1.4 |2021-04-26 |CRAN (R 4.4.0) | +|jsonlite |2.0.0 |2025-03-27 |CRAN (R 4.4.1) | +|jsonvalidate |1.5.0 |2025-02-07 |CRAN (R 4.4.1) | +|KernSmooth |2.23-26 |2025-01-01 |CRAN (R 4.4.1) | +|keyring |1.3.2 |2023-12-11 |CRAN (R 4.4.0) | +|knitr |1.50 |2025-03-16 |CRAN (R 4.4.1) | +|labeling |0.4.3 |2023-08-29 |CRAN (R 4.4.1) | +|later |1.4.2 |2025-04-08 |CRAN (R 4.4.1) | +|lattice |0.22-7 |2025-04-02 |CRAN (R 4.4.1) | +|lifecycle |1.0.4 |2023-11-07 |CRAN (R 4.4.1) | +|lme4 |1.1-37 |2025-03-26 |CRAN (R 4.4.1) | +|magrittr |2.0.3 |2022-03-30 |CRAN (R 4.4.1) | +|MASS |7.3-65 |2025-02-28 |CRAN (R 4.4.1) | +|Matrix |1.7-3 |2025-03-11 |CRAN (R 4.4.1) | +|memoise |2.0.1 |2021-11-26 |CRAN (R 4.4.0) | +|mime |0.13 |2025-03-17 |CRAN (R 4.4.1) | +|miniUI |0.1.2 |2025-04-17 |CRAN (R 4.4.1) | +|minqa |1.2.8 |2024-08-17 |CRAN (R 4.4.1) | +|modelbased |0.10.0 |2025-03-10 |CRAN (R 4.4.1) | +|nlme |3.1-168 |2025-03-31 |CRAN (R 4.4.1) | +|nloptr |2.2.1 |2025-03-17 |CRAN (R 4.4.1) | +|openssl |2.3.2 |2025-02-03 |CRAN (R 4.4.1) | +|openxlsx2 |1.15 |2025-04-25 |CRAN (R 4.4.1) | +|parameters |0.24.2 |2025-03-04 |CRAN (R 4.4.1) | +|patchwork |1.3.0 |2024-09-16 |CRAN (R 4.4.1) | +|performance |0.13.0 |2025-01-15 |CRAN (R 4.4.1) | +|phosphoricons |0.2.1 |2024-04-08 |CRAN (R 4.4.0) | +|pillar |1.10.2 |2025-04-05 |CRAN (R 4.4.1) | +|pkgbuild |1.4.7 |2025-03-24 |CRAN (R 4.4.1) | +|pkgconfig |2.0.3 |2019-09-22 |CRAN (R 4.4.1) | +|pkgload |1.4.0 |2024-06-28 |CRAN (R 4.4.0) | +|polyclip |1.10-7 |2024-07-23 |CRAN (R 4.4.1) | +|polylabelr |0.3.0 |2024-11-19 |CRAN (R 4.4.1) | +|processx |3.8.6 |2025-02-21 |CRAN (R 4.4.1) | +|profvis |0.4.0 |2024-09-20 |CRAN (R 4.4.1) | +|promises |1.3.2 |2024-11-28 |CRAN (R 4.4.1) | +|proxy |0.4-27 |2022-06-09 |CRAN (R 4.4.1) | +|ps |1.9.1 |2025-04-12 |CRAN (R 4.4.1) | +|purrr |1.0.4 |2025-02-05 |CRAN (R 4.4.1) | +|quarto |1.4.4 |2024-07-20 |CRAN (R 4.4.0) | +|R.cache |0.16.0 |2022-07-21 |CRAN (R 4.4.0) | +|R.methodsS3 |1.8.2 |2022-06-13 |CRAN (R 4.4.1) | +|R.oo |1.27.0 |2024-11-01 |CRAN (R 4.4.1) | +|R.utils |2.13.0 |2025-02-24 |CRAN (R 4.4.1) | +|R6 |2.6.1 |2025-02-15 |CRAN (R 4.4.1) | +|ragg |1.4.0 |2025-04-10 |CRAN (R 4.4.1) | +|rankinPlot |1.1.0 |2023-01-30 |CRAN (R 4.4.0) | +|rbibutils |2.3 |2024-10-04 |CRAN (R 4.4.1) | +|RColorBrewer |1.1-3 |2022-04-03 |CRAN (R 4.4.1) | +|Rcpp |1.0.14 |2025-01-12 |CRAN (R 4.4.1) | +|Rdpack |2.6.4 |2025-04-09 |CRAN (R 4.4.1) | +|reactable |0.4.4 |2023-03-12 |CRAN (R 4.4.0) | +|readODS |2.3.2 |2025-01-13 |CRAN (R 4.4.1) | +|readr |2.1.5 |2024-01-10 |CRAN (R 4.4.0) | +|readxl |1.4.5 |2025-03-07 |CRAN (R 4.4.1) | +|REDCapCAST |25.3.2 |2025-03-10 |CRAN (R 4.4.1) | +|REDCapR |1.4.0 |2025-01-11 |CRAN (R 4.4.1) | +|reformulas |0.4.0 |2024-11-03 |CRAN (R 4.4.1) | +|remotes |2.5.0 |2024-03-17 |CRAN (R 4.4.1) | +|renv |1.1.4 |2025-03-20 |CRAN (R 4.4.1) | +|report |0.6.1 |2025-02-07 |CRAN (R 4.4.1) | +|rio |1.2.3 |2024-09-25 |CRAN (R 4.4.1) | +|rlang |1.1.6 |2025-04-11 |CRAN (R 4.4.1) | +|rmarkdown |2.29 |2024-11-04 |CRAN (R 4.4.1) | +|roxygen2 |7.3.2 |2024-06-28 |CRAN (R 4.4.0) | +|rprojroot |2.0.4 |2023-11-05 |CRAN (R 4.4.1) | +|rsconnect |1.3.4 |2025-01-22 |CRAN (R 4.4.1) | +|rstudioapi |0.17.1 |2024-10-22 |CRAN (R 4.4.1) | +|sass |0.4.10 |2025-04-11 |CRAN (R 4.4.1) | +|scales |1.4.0 |2025-04-24 |CRAN (R 4.4.1) | +|see |0.11.0 |2025-03-11 |CRAN (R 4.4.1) | +|sessioninfo |1.2.3 |2025-02-05 |CRAN (R 4.4.1) | +|shiny |1.10.0 |2024-12-14 |CRAN (R 4.4.1) | +|shinybusy |0.3.3 |2024-03-09 |CRAN (R 4.4.0) | +|shinyjs |2.1.0 |2021-12-23 |CRAN (R 4.4.0) | +|shinyTime |1.0.3 |2022-08-19 |CRAN (R 4.4.0) | +|shinyWidgets |0.9.0 |2025-02-21 |CRAN (R 4.4.1) | +|stringi |1.8.7 |2025-03-27 |CRAN (R 4.4.1) | +|stringr |1.5.1 |2023-11-14 |CRAN (R 4.4.0) | +|styler |1.10.3 |2024-04-07 |CRAN (R 4.4.0) | +|systemfonts |1.2.2 |2025-04-04 |CRAN (R 4.4.1) | +|textshaping |1.0.0 |2025-01-20 |CRAN (R 4.4.1) | +|tibble |3.2.1 |2023-03-20 |CRAN (R 4.4.0) | +|tidyr |1.3.1 |2024-01-24 |CRAN (R 4.4.1) | +|tidyselect |1.2.1 |2024-03-11 |CRAN (R 4.4.0) | +|toastui |0.4.0 |2025-04-03 |CRAN (R 4.4.1) | +|tweenr |2.0.3 |2024-02-26 |CRAN (R 4.4.0) | +|tzdb |0.5.0 |2025-03-15 |CRAN (R 4.4.1) | +|urlchecker |1.0.1 |2021-11-30 |CRAN (R 4.4.1) | +|usethis |3.1.0 |2024-11-26 |CRAN (R 4.4.1) | +|utf8 |1.2.4 |2023-10-22 |CRAN (R 4.4.1) | +|V8 |6.0.3 |2025-03-26 |CRAN (R 4.4.1) | +|vctrs |0.6.5 |2023-12-01 |CRAN (R 4.4.0) | +|viridis |0.6.5 |2024-01-29 |CRAN (R 4.4.0) | +|viridisLite |0.4.2 |2023-05-02 |CRAN (R 4.4.1) | +|vroom |1.6.5 |2023-12-05 |CRAN (R 4.4.0) | +|withr |3.0.2 |2024-10-28 |CRAN (R 4.4.1) | +|writexl |1.5.4 |2025-04-15 |CRAN (R 4.4.1) | +|xfun |0.52 |2025-04-02 |CRAN (R 4.4.1) | +|xml2 |1.3.8 |2025-03-14 |CRAN (R 4.4.1) | +|xtable |1.8-4 |2019-04-21 |CRAN (R 4.4.1) | +|yaml |2.3.10 |2024-07-26 |CRAN (R 4.4.1) | +|zip |2.3.2 |2025-02-01 |CRAN (R 4.4.1) | diff --git a/inst/apps/FreesearchR/app.R b/inst/apps/FreesearchR/app.R index be0bb4da..646d4417 100644 --- a/inst/apps/FreesearchR/app.R +++ b/inst/apps/FreesearchR/app.R @@ -49,7 +49,7 @@ library(rlang) #### Current file: /Users/au301842/FreesearchR/R//app_version.R ######## -app_version <- function()'25.5.5' +app_version <- function()'25.5.4' ######## @@ -3996,7 +3996,7 @@ simple_snake <- function(data){ #### Current file: /Users/au301842/FreesearchR/R//hosted_version.R ######## -hosted_version <- function()'v25.5.5-250514' +hosted_version <- function()'v25.5.4-250513' ######## @@ -7134,7 +7134,7 @@ regression_table_create <- function(x, ..., args.list = NULL, fun = "gtsummary:: } } - gtsummary::theme_gtsummary_journal(journal = theme) + # gtsummary::theme_gtsummary_journal(journal = theme) if (inherits(x, "polr")) { # browser() out <- do.call(getfun(fun), c(list(x = x), args.list)) @@ -7505,7 +7505,7 @@ regression_server <- function(id, ############################################################################## ######### - ######### Regression models + ######### Regression analysis ######### ############################################################################## @@ -7553,179 +7553,6 @@ regression_server <- function(id, } ) - - - shiny::observeEvent( - list( - data_r(), - regression_vars() - ), - { - rv$list$regression$tables <- NULL - } - ) - - ############################################################################## - ######### - ######### Regression table - ######### - ############################################################################## - - ### Creating the regression table - shiny::observeEvent( - input$load, - { - shiny::req(rv$list$regression$models) - ## To avoid plotting old models on fail/error - rv$list$regression$tables <- NULL - - # browser() - tryCatch( - { - parameters <- list( - p.values = input$add_regression_p == "no" - ) - - out <- lapply(rv$list$regression$models, \(.x){ - .x$model - }) |> - purrr::map(\(.x){ - do.call( - regression_table, - append_list(.x, parameters, "x") - ) - }) - - rv$list$regression$models |> - purrr::imap(\(.x, .i){ - rv$list$regression$models[[.i]][["code_table"]] <- paste( - .x$code, - expression_string(rlang::call2(.fn = "regression_table", !!!parameters, .ns = "FreesearchR"), assign.str = NULL), - sep = "|>\n" - ) - }) - - rv$list$regression$tables <- out - rv$list$input <- input - }, - warning = function(warn) { - showNotification(paste0(warn), type = "warning") - }, - error = function(err) { - showNotification(paste0("Creating a regression table failed with the following error: ", err), type = "err") - } - ) - } - ) - - ## Consider creating merged table with theming and then passing object - ## to render. - - output$table2 <- gt::render_gt({ - ## Print checks if a regression table is present - if (!is.null(rv$list$regression$tables)) { - # gtsummary::theme_gtsummary_journal(journal = "jama") - merged <- rv$list$regression$tables |> - tbl_merge() - - if (input$add_regression_p == "no") { - merged <- merged |> - gtsummary::modify_column_hide(column = dplyr::starts_with("p.value")) - } - - out <- merged |> - gtsummary::as_gt() |> - gt::tab_header(gt::md(glue::glue("**Table 2: {rv$list$regression$params$descr}**"))) - - # rv$list$regression$table_merged <- out - - out - } else { - return(NULL) - } - }) - - ############################################################################## - ######### - ######### Coefficients plot - ######### - ############################################################################## - - shiny::observeEvent(list( - input$plot_model, - rv$list$regression - ), { - shiny::req(input$plot_model) - - tryCatch( - { - p <- merge_long( - rv$list$regression, - sort_by( - input$plot_model, - c("Univariable", "Minimal", "Multivariable"), - na.rm = TRUE - ) - ) |> - (\(.x){ - if (length(input$plot_model) > 1) { - plot.tbl_regression( - x = .x, - colour = "model", - dodged = TRUE - ) + - ggplot2::theme(legend.position = "bottom") + - ggplot2::guides(color = ggplot2::guide_legend(reverse = TRUE)) - } else { - plot.tbl_regression( - x = .x, - colour = "variable" - ) + - ggplot2::theme(legend.position = "none") - } - })() - - rv$plot <- p + - ggplot2::scale_y_discrete(labels = scales::label_wrap(15)) + - gg_theme_shiny() - }, - error = function(err) { - showNotification(paste0(err), type = "err") - } - ) - }) - - - output$regression_plot <- shiny::renderPlot( - { - shiny::req(input$plot_model) - - rv$plot - }, - alt = "Regression coefficient plot" - ) - - # plot_download_server( - # id = ns("reg_plot_download"), - # data = shiny::reactive(rv$plot) - # ) - - output$download_plot <- shiny::downloadHandler( - filename = paste0("regression_plot.", input$plot_type), - content = function(file) { - shiny::withProgress(message = "Saving the plot. Hold on for a moment..", { - ggplot2::ggsave( - filename = file, - plot = rv$plot, - width = input$plot_width, - height = input$plot_height, - dpi = 300, - units = "mm", scale = 2 - ) - }) - } - ) - ############################################################################## ######### ######### Model checks @@ -7833,6 +7660,171 @@ regression_server <- function(id, alt = "Assumptions testing of the multivariable regression model" ) + shiny::observeEvent( + list( + data_r(), + regression_vars() + ), + { + rv$list$regression$tables <- NULL + } + ) + + ### Creating the regression table + shiny::observeEvent( + input$load, + { + shiny::req(rv$list$regression$models) + ## To avoid plotting old models on fail/error + rv$list$regression$tables <- NULL + + # browser() + tryCatch( + { + parameters <- list( + p.values = input$add_regression_p == "no" + ) + + out <- lapply(rv$list$regression$models, \(.x){ + .x$model + }) |> + purrr::map(\(.x){ + do.call( + regression_table, + append_list(.x, parameters, "x") + ) + }) + + rv$list$regression$models |> + purrr::imap(\(.x, .i){ + rv$list$regression$models[[.i]][["code_table"]] <- paste( + .x$code, + expression_string(rlang::call2(.fn = "regression_table", !!!parameters, .ns = "FreesearchR"), assign.str = NULL), + sep = "|>\n" + ) + }) + + rv$list$regression$tables <- out + rv$list$input <- input + }, + warning = function(warn) { + showNotification(paste0(warn), type = "warning") + }, + error = function(err) { + showNotification(paste0("Creating a regression table failed with the following error: ", err), type = "err") + } + ) + } + ) + + ## Consider creating merged table with theming and then passing object + ## to render. + + output$table2 <- gt::render_gt({ + ## Print checks if a regression table is present + if (!is.null(rv$list$regression$tables)) { + gtsummary::theme_gtsummary_journal(journal = "jama") + merged <- rv$list$regression$tables |> + tbl_merge() + + if (input$add_regression_p == "no") { + merged <- merged |> + gtsummary::modify_column_hide(column = dplyr::starts_with("p.value")) + } + + out <- merged |> + gtsummary::as_gt() |> + gt::tab_header(gt::md(glue::glue("**Table 2: {rv$list$regression$params$descr}**"))) + + rv$list$regression$table_merged + + out + } else { + return(NULL) + } + }) + + ############################################################################## + ######### + ######### Coefficients plot + ######### + ############################################################################## + + shiny::observeEvent(list( + input$plot_model, + rv$list$regression + ), { + shiny::req(input$plot_model) + + tryCatch( + { + p <- merge_long( + rv$list$regression, + sort_by( + input$plot_model, + c("Univariable", "Minimal", "Multivariable"), + na.rm = TRUE + ) + ) |> + (\(.x){ + if (length(input$plot_model) > 1) { + plot.tbl_regression( + x = .x, + colour = "model", + dodged = TRUE + ) + + ggplot2::theme(legend.position = "bottom") + + ggplot2::guides(color = ggplot2::guide_legend(reverse = TRUE)) + } else { + plot.tbl_regression( + x = .x, + colour = "variable" + ) + + ggplot2::theme(legend.position = "none") + } + })() + + rv$plot <- p + + ggplot2::scale_y_discrete(labels = scales::label_wrap(15)) + + gg_theme_shiny() + }, + error = function(err) { + showNotification(paste0(err), type = "err") + } + ) + }) + + + output$regression_plot <- shiny::renderPlot( + { + shiny::req(input$plot_model) + + rv$plot + }, + alt = "Regression coefficient plot" + ) + + # plot_download_server( + # id = ns("reg_plot_download"), + # data = shiny::reactive(rv$plot) + # ) + + output$download_plot <- shiny::downloadHandler( + filename = paste0("regression_plot.", input$plot_type), + content = function(file) { + shiny::withProgress(message = "Saving the plot. Hold on for a moment..", { + ggplot2::ggsave( + filename = file, + plot = rv$plot, + width = input$plot_width, + height = input$plot_height, + dpi = 300, + units = "mm", scale = 2 + ) + }) + } + ) + ############################################################################## ######### ######### Output diff --git a/renv.lock b/renv.lock index 074b3f4f..8172a379 100644 --- a/renv.lock +++ b/renv.lock @@ -2710,86 +2710,6 @@ "Author": "Mattan S. Ben-Shachar [aut, cre] (), Dominique Makowski [aut] (), Daniel Lüdecke [aut] (), Indrajeet Patil [aut] (), Brenton M. Wiernik [aut] (), Rémi Thériault [aut] (), Ken Kelley [ctb], David Stanley [ctb], Aaron Caldwell [ctb] (), Jessica Burnett [rev] (), Johannes Karreth [rev] (), Philip Waggoner [aut, ctb] ()", "Repository": "CRAN" }, - "emmeans": { - "Package": "emmeans", - "Version": "1.11.1", - "Source": "Repository", - "Type": "Package", - "Title": "Estimated Marginal Means, aka Least-Squares Means", - "Date": "2025-05-03", - "Authors@R": "c(person(\"Russell V.\", \"Lenth\", role = c(\"aut\", \"cre\", \"cph\"), email = \"russell-lenth@uiowa.edu\"), person(\"Balazs\", \"Banfai\", role = \"ctb\"), person(\"Ben\", \"Bolker\", role = \"ctb\"), person(\"Paul\", \"Buerkner\", role = \"ctb\"), person(\"Iago\", \"Giné-Vázquez\", role = \"ctb\"), person(\"Maxime\", \"Herve\", role = \"ctb\"), person(\"Maarten\", \"Jung\", role = \"ctb\"), person(\"Jonathon\", \"Love\", role = \"ctb\"), person(\"Fernando\", \"Miguez\", role = \"ctb\"), person(\"Julia\", \"Piaskowski\", role = \"ctb\"), person(\"Hannes\", \"Riebl\", role = \"ctb\"), person(\"Henrik\", \"Singmann\", role = \"ctb\"))", - "Depends": [ - "R (>= 4.1.0)" - ], - "Imports": [ - "estimability (>= 1.4.1)", - "graphics", - "methods", - "mvtnorm", - "numDeriv", - "stats", - "utils" - ], - "Suggests": [ - "bayesplot", - "bayestestR", - "biglm", - "brms", - "car", - "coda (>= 0.17)", - "compositions", - "ggplot2", - "knitr", - "lattice", - "lme4", - "lmerTest (>= 2.0.32)", - "logspline", - "MASS", - "mediation", - "mgcv", - "multcomp", - "multcompView", - "MuMIn", - "nlme", - "ordinal (>= 2014.11-12)", - "pbkrtest (>= 0.4-1)", - "rmarkdown", - "rsm", - "sandwich", - "scales", - "splines", - "testthat", - "tibble", - "xtable (>= 1.8-2)" - ], - "Enhances": [ - "CARBayes", - "coxme", - "gee", - "geepack", - "MCMCglmm", - "MCMCpack", - "mice", - "nnet", - "pscl", - "rstanarm", - "sommer", - "survival" - ], - "URL": "https://rvlenth.github.io/emmeans/,https://rvlenth.github.io/emmeans/", - "BugReports": "https://github.com/rvlenth/emmeans/issues", - "LazyData": "yes", - "ByteCompile": "yes", - "Description": "Obtain estimated marginal means (EMMs) for many linear, generalized linear, and mixed models. Compute contrasts or linear functions of EMMs, trends, and comparisons of slopes. Plots and other displays. Least-squares means are discussed, and the term \"estimated marginal means\" is suggested, in Searle, Speed, and Milliken (1980) Population marginal means in the linear model: An alternative to least squares means, The American Statistician 34(4), 216-221 .", - "License": "GPL-2 | GPL-3", - "Encoding": "UTF-8", - "RoxygenNote": "7.3.2", - "VignetteBuilder": "knitr", - "NeedsCompilation": "no", - "Author": "Russell V. Lenth [aut, cre, cph], Balazs Banfai [ctb], Ben Bolker [ctb], Paul Buerkner [ctb], Iago Giné-Vázquez [ctb], Maxime Herve [ctb], Maarten Jung [ctb], Jonathon Love [ctb], Fernando Miguez [ctb], Julia Piaskowski [ctb], Hannes Riebl [ctb], Henrik Singmann [ctb]", - "Maintainer": "Russell V. Lenth ", - "Repository": "CRAN" - }, "esquisse": { "Package": "esquisse", "Version": "2.1.0", @@ -2837,33 +2757,6 @@ "Maintainer": "Victor Perrier ", "Repository": "CRAN" }, - "estimability": { - "Package": "estimability", - "Version": "1.5.1", - "Source": "Repository", - "Type": "Package", - "Title": "Tools for Assessing Estimability of Linear Predictions", - "Date": "2024-05-12", - "Authors@R": "c(person(\"Russell\", \"Lenth\", role = c(\"aut\", \"cre\", \"cph\"), email = \"russell-lenth@uiowa.edu\"))", - "Depends": [ - "stats", - "R(>= 4.1.0)" - ], - "Suggests": [ - "knitr", - "rmarkdown" - ], - "Description": "Provides tools for determining estimability of linear functions of regression coefficients, and 'epredict' methods that handle non-estimable cases correctly. Estimability theory is discussed in many linear-models textbooks including Chapter 3 of Monahan, JF (2008), \"A Primer on Linear Models\", Chapman and Hall (ISBN 978-1-4200-6201-4).", - "URL": "https://github.com/rvlenth/estimability, https://rvlenth.github.io/estimability/", - "BugReports": "https://github.com/rvlenth/estimability/issues", - "ByteCompile": "yes", - "License": "GPL (>= 3)", - "VignetteBuilder": "knitr", - "NeedsCompilation": "no", - "Author": "Russell Lenth [aut, cre, cph]", - "Maintainer": "Russell Lenth ", - "Repository": "CRAN" - }, "eulerr": { "Package": "eulerr", "Version": "7.0.2", @@ -5514,31 +5407,6 @@ "Author": "Dominique Makowski [aut, cre] (), Daniel Lüdecke [aut] (), Mattan S. Ben-Shachar [aut] (), Indrajeet Patil [aut] (), Rémi Thériault [aut] ()", "Repository": "CRAN" }, - "mvtnorm": { - "Package": "mvtnorm", - "Version": "1.3-3", - "Source": "Repository", - "Title": "Multivariate Normal and t Distributions", - "Date": "2025-01-09", - "Authors@R": "c(person(\"Alan\", \"Genz\", role = \"aut\"), person(\"Frank\", \"Bretz\", role = \"aut\"), person(\"Tetsuhisa\", \"Miwa\", role = \"aut\"), person(\"Xuefei\", \"Mi\", role = \"aut\"), person(\"Friedrich\", \"Leisch\", role = \"ctb\"), person(\"Fabian\", \"Scheipl\", role = \"ctb\"), person(\"Bjoern\", \"Bornkamp\", role = \"ctb\", comment = c(ORCID = \"0000-0002-6294-8185\")), person(\"Martin\", \"Maechler\", role = \"ctb\", comment = c(ORCID = \"0000-0002-8685-9910\")), person(\"Torsten\", \"Hothorn\", role = c(\"aut\", \"cre\"), email = \"Torsten.Hothorn@R-project.org\", comment = c(ORCID = \"0000-0001-8301-0471\")))", - "Description": "Computes multivariate normal and t probabilities, quantiles, random deviates, and densities. Log-likelihoods for multivariate Gaussian models and Gaussian copulae parameterised by Cholesky factors of covariance or precision matrices are implemented for interval-censored and exact data, or a mix thereof. Score functions for these log-likelihoods are available. A class representing multiple lower triangular matrices and corresponding methods are part of this package.", - "Imports": [ - "stats" - ], - "Depends": [ - "R(>= 3.5.0)" - ], - "Suggests": [ - "qrng", - "numDeriv" - ], - "License": "GPL-2", - "URL": "http://mvtnorm.R-forge.R-project.org", - "NeedsCompilation": "yes", - "Author": "Alan Genz [aut], Frank Bretz [aut], Tetsuhisa Miwa [aut], Xuefei Mi [aut], Friedrich Leisch [ctb], Fabian Scheipl [ctb], Bjoern Bornkamp [ctb] (), Martin Maechler [ctb] (), Torsten Hothorn [aut, cre] ()", - "Maintainer": "Torsten Hothorn ", - "Repository": "CRAN" - }, "nlme": { "Package": "nlme", "Version": "3.1-168", @@ -5625,26 +5493,6 @@ "Maintainer": "Brian Ripley ", "Repository": "CRAN" }, - "numDeriv": { - "Package": "numDeriv", - "Version": "2016.8-1.1", - "Source": "Repository", - "Title": "Accurate Numerical Derivatives", - "Description": "Methods for calculating (usually) accurate numerical first and second order derivatives. Accurate calculations are done using 'Richardson''s' extrapolation or, when applicable, a complex step derivative is available. A simple difference method is also provided. Simple difference is (usually) less accurate but is much quicker than 'Richardson''s' extrapolation and provides a useful cross-check. Methods are provided for real scalar and vector valued functions.", - "Depends": [ - "R (>= 2.11.1)" - ], - "LazyLoad": "yes", - "ByteCompile": "yes", - "License": "GPL-2", - "Copyright": "2006-2011, Bank of Canada. 2012-2016, Paul Gilbert", - "Author": "Paul Gilbert and Ravi Varadhan", - "Maintainer": "Paul Gilbert ", - "URL": "http://optimizer.r-forge.r-project.org/", - "NeedsCompilation": "no", - "Repository": "RSPM", - "Encoding": "UTF-8" - }, "officer": { "Package": "officer", "Version": "0.6.8",