From f73af16ae117d4f292f8490ee6993a7c4ca8c5ae Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Mon, 31 Mar 2025 14:37:28 +0200 Subject: [PATCH] updated docs --- NAMESPACE | 1 + R/app_version.R | 2 +- R/correlations-module.R | 10 +++++++- R/helpers.R | 21 +++++++++++++++++ R/regression_plot.R | 2 +- R/theme.R | 3 +-- inst/apps/FreesearchR/app.R | 23 ++++++++++++------- .../shinyapps.io/agdamsbo/freesearcheR.dcf | 2 +- inst/apps/FreesearchR/server.R | 6 ++--- man/cor_demo_app.Rd | 16 +++++++++++++ 10 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 man/cor_demo_app.Rd diff --git a/NAMESPACE b/NAMESPACE index 9480d52..0a03a18 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(clean_date) export(clean_sep) export(columnSelectInput) export(contrast_text) +export(cor_demo_app) export(create_baseline) export(create_log_tics) export(create_overview_datagrid) diff --git a/R/app_version.R b/R/app_version.R index 9054157..0408af9 100644 --- a/R/app_version.R +++ b/R/app_version.R @@ -1 +1 @@ -app_version <- function()'250326_1206' +app_version <- function()'250331_1248' diff --git a/R/correlations-module.R b/R/correlations-module.R index f69daef..6b2476a 100644 --- a/R/correlations-module.R +++ b/R/correlations-module.R @@ -133,6 +133,15 @@ sentence_paste <- function(data, and.str = "and") { } +#' Correlations plot demo app +#' +#' @returns +#' @export +#' +#' @examples +#' \dontrun{ +#' cor_demo_app() +#' } cor_demo_app <- function() { ui <- shiny::fluidPage( shiny::sliderInput( @@ -152,4 +161,3 @@ cor_demo_app <- function() { shiny::shinyApp(ui, server) } -cor_demo_app() diff --git a/R/helpers.R b/R/helpers.R index a15a54a..2571fad 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -342,3 +342,24 @@ data_description <- function(data) { signif(100 * p_complete, 3) ) } + +#' Drop-in replacement for the base::sort_by with option to remove NAs +#' +#' @param x x +#' @param y y +#' @param na.rm remove NAs +#' @param ... passed to base_sort_by +#' +#' @returns +#' @export +#' +#' @examples +#' sort_by(c("Multivariable", "Univariable"),c("Univariable","Minimal","Multivariable")) +sort_by <- function(x,y,na.rm=FALSE,...){ + out <- base::sort_by(x,y,...) + if (na.rm==TRUE){ + out[!is.na(out)] + } else { + out + } +} diff --git a/R/regression_plot.R b/R/regression_plot.R index a21a4bf..5c61294 100644 --- a/R/regression_plot.R +++ b/R/regression_plot.R @@ -91,7 +91,7 @@ merge_long <- function(list, model.names) { setNames(d, gsub("_[0-9]{,}$", "", names(d))) }) |> dplyr::bind_rows() |> - dplyr::mutate(model = as_factor(model)) + dplyr::mutate(model = REDCapCAST::as_factor(model)) l_merged$table_body <- df_body_long diff --git a/R/theme.R b/R/theme.R index ea0b3f9..15fc5f4 100644 --- a/R/theme.R +++ b/R/theme.R @@ -52,8 +52,7 @@ gg_theme_shiny <- function(){ legend.title = ggplot2::element_text(size = 18), legend.text = ggplot2::element_text(size = 14), plot.title = ggplot2::element_text(size = 24), - plot.subtitle = ggplot2::element_text(size = 18), - legend.position = "none" + plot.subtitle = ggplot2::element_text(size = 18) ) } diff --git a/inst/apps/FreesearchR/app.R b/inst/apps/FreesearchR/app.R index 24b4e8d..c7c02f9 100644 --- a/inst/apps/FreesearchR/app.R +++ b/inst/apps/FreesearchR/app.R @@ -10,7 +10,7 @@ #### Current file: R//app_version.R ######## -app_version <- function()'250326_1206' +app_version <- function()'250331_1248' ######## @@ -289,6 +289,15 @@ sentence_paste <- function(data, and.str = "and") { } +#' Correlations plot demo app +#' +#' @returns +#' @export +#' +#' @examples +#' \dontrun{ +#' cor_demo_app() +#' } cor_demo_app <- function() { ui <- shiny::fluidPage( shiny::sliderInput( @@ -308,7 +317,6 @@ cor_demo_app <- function() { shiny::shinyApp(ui, server) } -cor_demo_app() ######## @@ -5417,7 +5425,7 @@ merge_long <- function(list, model.names) { setNames(d, gsub("_[0-9]{,}$", "", names(d))) }) |> dplyr::bind_rows() |> - dplyr::mutate(model = as_factor(model)) + dplyr::mutate(model = REDCapCAST::as_factor(model)) l_merged$table_body <- df_body_long @@ -5781,8 +5789,7 @@ gg_theme_shiny <- function(){ legend.title = ggplot2::element_text(size = 18), legend.text = ggplot2::element_text(size = 14), plot.title = ggplot2::element_text(size = 24), - plot.subtitle = ggplot2::element_text(size = 18), - legend.position = "none" + plot.subtitle = ggplot2::element_text(size = 18) ) } @@ -8541,9 +8548,9 @@ server <- function(input, output, session) { alt = "Regression coefficient plot" ) - shiny::conditionalPanel( - condition = "output.uploaded == 'yes'", - ) + # shiny::conditionalPanel( + # condition = "output.uploaded == 'yes'", + # ) ############################################################################## ######### diff --git a/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf b/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf index bce11d6..41e9d93 100644 --- a/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf +++ b/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf @@ -5,6 +5,6 @@ account: agdamsbo server: shinyapps.io hostUrl: https://api.shinyapps.io/v1 appId: 13611288 -bundleId: 9994404 +bundleId: 10005865 url: https://agdamsbo.shinyapps.io/freesearcheR/ version: 1 diff --git a/inst/apps/FreesearchR/server.R b/inst/apps/FreesearchR/server.R index 790d2dd..1a61ad0 100644 --- a/inst/apps/FreesearchR/server.R +++ b/inst/apps/FreesearchR/server.R @@ -844,9 +844,9 @@ server <- function(input, output, session) { alt = "Regression coefficient plot" ) - shiny::conditionalPanel( - condition = "output.uploaded == 'yes'", - ) + # shiny::conditionalPanel( + # condition = "output.uploaded == 'yes'", + # ) ############################################################################## ######### diff --git a/man/cor_demo_app.Rd b/man/cor_demo_app.Rd new file mode 100644 index 0000000..fe1fe3c --- /dev/null +++ b/man/cor_demo_app.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/correlations-module.R +\name{cor_demo_app} +\alias{cor_demo_app} +\title{Correlations plot demo app} +\usage{ +cor_demo_app() +} +\description{ +Correlations plot demo app +} +\examples{ +\dontrun{ +cor_demo_app() +} +}