diff --git a/R/get_dt_rows.R b/R/get_dt_rows.R index 906a460a..4e3d99f0 100644 --- a/R/get_dt_rows.R +++ b/R/get_dt_rows.R @@ -1,8 +1,9 @@ -#' Maps the `lengthMenu`selected value property of `DT::datatable` to a Shiny variable. +#' Map `lenghtMenu` property #' -#' @description `r lifecycle::badge("stable")` -#' @param dt_name \code{ns()} of `inputId` of the `DT::datatable` -#' @param dt_rows \code{ns()} of `inputId` of the variable that holds the current selected value of `lengthMenu` +#' @description `r lifecycle::badge("stable")`\cr +#' Maps the `lengthMenu` selected value property of `DT::datatable` to a `shiny` variable. +#' @param dt_name `ns()` of `inputId` of the `DT::datatable` +#' @param dt_rows `ns()` of `inputId` of the variable that holds the current selected value of `lengthMenu` #' #' @name get_dt_rows #' diff --git a/R/optionalInput.R b/R/optionalInput.R index c9305ff5..a38f45c2 100644 --- a/R/optionalInput.R +++ b/R/optionalInput.R @@ -450,7 +450,7 @@ extract_raw_choices <- function(choices, sep) { #' if min or max are `NA` then the slider widget will be hidden #' -#' @description `r lifecycle::badge("stable")` +#' @description `r lifecycle::badge("stable")`\cr #' Hidden input widgets are useful to have the `input[[inputId]]` variable #' on available in the server function but no corresponding visual clutter from #' input widgets that provide only a single choice. diff --git a/R/panel_group.R b/R/panel_group.R index 6319b2c8..0ff51d38 100644 --- a/R/panel_group.R +++ b/R/panel_group.R @@ -1,12 +1,50 @@ #' Panel group widget #' -#' @description `r lifecycle::badge("experimental")` +#' @description `r lifecycle::badge("experimental")`\cr +#' Designed to group [`panel_item`] elements. Used to handle `shiny` inputs in the encoding panel. #' @param id optional, (`character`)\cr #' @param ... (`shiny.tag`)\cr #' panels created by [panel_group()] #' #' @return (`shiny.tag`) #' +#' @examples +#' +#' library(shiny) +#' panel_group( +#' panel_item( +#' title = "Display", +#' collapsed = FALSE, +#' checkboxGroupInput( +#' "check", +#' "Tables display", +#' choices = LETTERS[1:3], +#' selected = LETTERS[1] +#' ), +#' radioButtons( +#' "radio", +#' label = "Plot type", +#' choices = letters[1:2], +#' selected = letters[1] +#' ) +#' ), +#' panel_item( +#' title = "Pre-processing", +#' radioButtons( +#' "filtering", +#' "What to filter", +#' choices = LETTERS[1:4], +#' selected = LETTERS[1] +#' ), +#' radioButtons( +#' "na_action", +#' "NA action", +#' choices = letters[1:3], +#' selected = letters[1] +#' ) +#' ) +#' ) +#' #' @export panel_group <- function(..., id = NULL) { checkmate::assert_string(id, null.ok = TRUE) @@ -34,10 +72,10 @@ panel_group <- function(..., id = NULL) { ) } -#' Panel widget -#' @md +#' Panel item widget #' -#' @description `r lifecycle::badge("experimental")` +#' @description `r lifecycle::badge("experimental")`\cr +#' Designed to be grouped using [`panel_group`] element. Used to handle `shiny` inputs in the encoding panel. #' @param title (`character`)\cr title of panel #' @param ... content of panel #' @param collapsed (`logical`, optional)\cr @@ -48,6 +86,26 @@ panel_group <- function(..., id = NULL) { #' #' @return (`shiny.tag`) #' +#' @examples +#' +#' library(shiny) +#' panel_item( +#' title = "Display", +#' collapsed = FALSE, +#' checkboxGroupInput( +#' "check", +#' "Tables display", +#' choices = LETTERS[1:3], +#' selected = LETTERS[1] +#' ), +#' radioButtons( +#' "radio", +#' label = "Plot type", +#' choices = letters[1:2], +#' selected = letters[1] +#' ) +#' ) +#' #' @export panel_item <- function(title, ..., collapsed = TRUE, input_id = NULL) { stopifnot(checkmate::test_character(title, len = 1) || inherits(title, c("shiny.tag", "shiny.tag.list", "html"))) diff --git a/R/plot_with_settings.R b/R/plot_with_settings.R index 4b8f2bc9..6f3c3316 100644 --- a/R/plot_with_settings.R +++ b/R/plot_with_settings.R @@ -1,3 +1,4 @@ +#' @name plot_with_settings #' @rdname plot_with_settings #' @export plot_with_settings_ui <- function(id) { @@ -61,7 +62,7 @@ plot_with_settings_ui <- function(id) { #' Plot-with-settings module #' #' @rdname plot_with_settings -#' @description `r lifecycle::badge("stable")` +#' @description `r lifecycle::badge("stable")`\cr #' Universal module for plots with settings for height, width, and download. #' #' @export @@ -596,15 +597,39 @@ type_download_srv <- function(id, plot_reactive, plot_type, plot_w, default_w, p ) } -#' Cleans and organizes output to account for NAs and remove empty rows. +#' Clean brushed points #' -#' @description `r lifecycle::badge("stable")` +#' @description `r lifecycle::badge("stable")`\cr +#' Cleans and organizes output to account for NAs and remove empty rows. Wrapper around `shiny::brushedPoints`. #' @param data (`data.frame`)\cr -#' A dataframe from which to select rows. +#' A data.frame from which to select rows. #' @param brush (`list`)\cr -#' The data from a brush e.g. input$plot_brush. +#' The data from a brush e.g. `input$plot_brush`. +#' +#' @return A `data.frame` of selected rows. +#' +#' @examples +#' +#' brush <- list( +#' mapping = list( +#' x = "AGE", +#' y = "BMRKR1" +#' ), +#' xmin = 30, xmax = 40, +#' ymin = 0.7, ymax = 10, +#' direction = "xy" +#' ) +#' +#' data <- data.frame( +#' STUDYID = letters[1:20], +#' USUBJID = LETTERS[1:20], +#' AGE = sample(25:40, size = 20, replace = TRUE), +#' BMRKR1 = runif(20, min = 0, max = 12) +#' ) +#' nrow(clean_brushedPoints(data, brush)) +#' data$AGE[1:10] <- NA +#' nrow(clean_brushedPoints(data, brush)) #' -#' @return A dataframe of selected rows. #' @export #' clean_brushedPoints <- function(data, brush) { # nolint object_name_linter. diff --git a/R/standard_layout.R b/R/standard_layout.R index cd004e96..73423bef 100644 --- a/R/standard_layout.R +++ b/R/standard_layout.R @@ -1,8 +1,8 @@ -#' Create a standard UI layout with output on the right and an encoding panel on -#' the left +#' Standard UI layout #' -#' @description `r lifecycle::badge("stable")` -#' This is the layout used by the `teal` modules. +#' @description `r lifecycle::badge("stable")`\cr +#' Create a standard UI layout with output on the right and an encoding panel on +#' the left. This is the layout used by the `teal` modules. #' #' @param output (`shiny.tag`)\cr #' object with the output element (table, plot, listing) such as for example returned @@ -19,6 +19,31 @@ #' #' @return an object of class \code{shiny.tag} with the UI code. #' +#' @examples +#' library(shiny) +#' standard_layout( +#' output = white_small_well(h3("Tests")), +#' encoding = div( +#' tags$label("Encodings", class = "text-primary"), +#' panel_item( +#' "Tests", +#' optionalSelectInput( +#' "tests", +#' "Tests:", +#' choices = c( +#' "Shapiro-Wilk", +#' "Kolmogorov-Smirnov (one-sample)" +#' ), +#' selected = "Shapiro-Wilk" +#' ) +#' ) +#' ), +#' forms = tagList( +#' verbatim_popup_ui("warning", "Show Warnings"), +#' verbatim_popup_ui("rcode", "Show R code") +#' ) +#' ) +#' #' @export standard_layout <- function(output, encoding = NULL, diff --git a/R/table_with_settings.R b/R/table_with_settings.R index e46cd876..9d34ebe6 100644 --- a/R/table_with_settings.R +++ b/R/table_with_settings.R @@ -1,8 +1,9 @@ #' @name table_with_settings #' -#' @title table_with_settings module +#' @title `table_with_settings` module #' -#' @description `r lifecycle::badge("stable")` +#' @description `r lifecycle::badge("stable")`\cr +#' Module designed to create a `shiny` table output based on `rtable` object (`ElementaryTable` or `TableTree`) input. #' @inheritParams shiny::moduleServer #' @param ... (`character`)\cr #' Useful for providing additional HTML classes for the output tag. diff --git a/R/white_small_well.R b/R/white_small_well.R index 1260dfb7..5e5cdd5d 100644 --- a/R/white_small_well.R +++ b/R/white_small_well.R @@ -1,6 +1,7 @@ -#' Adds Class Small Well and overflow-x property to HTML output element +#' Small well class for HTML #' -#' @description `r lifecycle::badge("stable")` +#' @description `r lifecycle::badge("stable")`\cr +#' Adds Small Well class and overflow-x property to HTML output element. #' @param ... other arguments to pass to tag object's div attributes. #' #' @details `white_small_well` is intended to be used with [shiny::uiOutput()]. diff --git a/man/clean_brushedPoints.Rd b/man/clean_brushedPoints.Rd index 76e17595..36980fe0 100644 --- a/man/clean_brushedPoints.Rd +++ b/man/clean_brushedPoints.Rd @@ -2,20 +2,44 @@ % Please edit documentation in R/plot_with_settings.R \name{clean_brushedPoints} \alias{clean_brushedPoints} -\title{Cleans and organizes output to account for NAs and remove empty rows.} +\title{Clean brushed points} \usage{ clean_brushedPoints(data, brush) } \arguments{ \item{data}{(\code{data.frame})\cr -A dataframe from which to select rows.} +A data.frame from which to select rows.} \item{brush}{(\code{list})\cr -The data from a brush e.g. input$plot_brush.} +The data from a brush e.g. \code{input$plot_brush}.} } \value{ -A dataframe of selected rows. +A \code{data.frame} of selected rows. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr +Cleans and organizes output to account for NAs and remove empty rows. Wrapper around \code{shiny::brushedPoints}. +} +\examples{ + +brush <- list( + mapping = list( + x = "AGE", + y = "BMRKR1" + ), + xmin = 30, xmax = 40, + ymin = 0.7, ymax = 10, + direction = "xy" +) + +data <- data.frame( + STUDYID = letters[1:20], + USUBJID = LETTERS[1:20], + AGE = sample(25:40, size = 20, replace = TRUE), + BMRKR1 = runif(20, min = 0, max = 12) +) +nrow(clean_brushedPoints(data, brush)) +data$AGE[1:10] <- NA +nrow(clean_brushedPoints(data, brush)) + } diff --git a/man/get_dt_rows.Rd b/man/get_dt_rows.Rd index 34d1a11f..36ee4b96 100644 --- a/man/get_dt_rows.Rd +++ b/man/get_dt_rows.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/get_dt_rows.R \name{get_dt_rows} \alias{get_dt_rows} -\title{Maps the \code{lengthMenu}selected value property of \code{DT::datatable} to a Shiny variable.} +\title{Map \code{lenghtMenu} property} \usage{ get_dt_rows(dt_name, dt_rows) } @@ -15,7 +15,8 @@ get_dt_rows(dt_name, dt_rows) (\code{shiny::tagList}) A \verb{shiny tagList}. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr +Maps the \code{lengthMenu} selected value property of \code{DT::datatable} to a \code{shiny} variable. } \examples{ library(shiny) diff --git a/man/optionalSliderInput.Rd b/man/optionalSliderInput.Rd index cbdf2200..77d2dbe9 100644 --- a/man/optionalSliderInput.Rd +++ b/man/optionalSliderInput.Rd @@ -28,7 +28,7 @@ an object of class \code{shiny.tag}. E.g. an object returned by \code{\link[shin (\code{shiny.tag}) HTML tag with \code{sliderInput} widget. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr Hidden input widgets are useful to have the \code{input[[inputId]]} variable on available in the server function but no corresponding visual clutter from input widgets that provide only a single choice. diff --git a/man/panel_group.Rd b/man/panel_group.Rd index 18b422de..a5416b4a 100644 --- a/man/panel_group.Rd +++ b/man/panel_group.Rd @@ -16,5 +16,44 @@ panels created by \code{\link[=panel_group]{panel_group()}}} (\code{shiny.tag}) } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}\cr +Designed to group \code{\link{panel_item}} elements. Used to handle \code{shiny} inputs in the encoding panel. +} +\examples{ + +library(shiny) +panel_group( + panel_item( + title = "Display", + collapsed = FALSE, + checkboxGroupInput( + "check", + "Tables display", + choices = LETTERS[1:3], + selected = LETTERS[1] + ), + radioButtons( + "radio", + label = "Plot type", + choices = letters[1:2], + selected = letters[1] + ) + ), + panel_item( + title = "Pre-processing", + radioButtons( + "filtering", + "What to filter", + choices = LETTERS[1:4], + selected = LETTERS[1] + ), + radioButtons( + "na_action", + "NA action", + choices = letters[1:3], + selected = letters[1] + ) + ) +) + } diff --git a/man/panel_item.Rd b/man/panel_item.Rd index c16307d0..b8ef5db8 100644 --- a/man/panel_item.Rd +++ b/man/panel_item.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/panel_group.R \name{panel_item} \alias{panel_item} -\title{Panel widget} +\title{Panel item widget} \usage{ panel_item(title, ..., collapsed = TRUE, input_id = NULL) } @@ -22,5 +22,27 @@ indicates whether the panel item is open or collapsed and is accessed with \code (\code{shiny.tag}) } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}\cr +Designed to be grouped using \code{\link{panel_group}} element. Used to handle \code{shiny} inputs in the encoding panel. +} +\examples{ + +library(shiny) +panel_item( + title = "Display", + collapsed = FALSE, + checkboxGroupInput( + "check", + "Tables display", + choices = LETTERS[1:3], + selected = LETTERS[1] + ), + radioButtons( + "radio", + label = "Plot type", + choices = letters[1:2], + selected = letters[1] + ) +) + } diff --git a/man/plot_with_settings.Rd b/man/plot_with_settings.Rd index c38cadc6..32289b17 100644 --- a/man/plot_with_settings.Rd +++ b/man/plot_with_settings.Rd @@ -1,6 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot_with_settings.R -\name{plot_with_settings_ui} +\name{plot_with_settings} +\alias{plot_with_settings} \alias{plot_with_settings_ui} \alias{plot_with_settings_srv} \title{Plot-with-settings module} @@ -69,7 +70,7 @@ the main page.} A \code{shiny} module. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr Universal module for plots with settings for height, width, and download. } \details{ diff --git a/man/standard_layout.Rd b/man/standard_layout.Rd index 33f8437a..b0630dec 100644 --- a/man/standard_layout.Rd +++ b/man/standard_layout.Rd @@ -2,8 +2,7 @@ % Please edit documentation in R/standard_layout.R \name{standard_layout} \alias{standard_layout} -\title{Create a standard UI layout with output on the right and an encoding panel on -the left} +\title{Standard UI layout} \usage{ standard_layout( output, @@ -35,6 +34,33 @@ into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} el an object of class \code{shiny.tag} with the UI code. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} -This is the layout used by the \code{teal} modules. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr +Create a standard UI layout with output on the right and an encoding panel on +the left. This is the layout used by the \code{teal} modules. +} +\examples{ +library(shiny) +standard_layout( + output = white_small_well(h3("Tests")), + encoding = div( + tags$label("Encodings", class = "text-primary"), + panel_item( + "Tests", + optionalSelectInput( + "tests", + "Tests:", + choices = c( + "Shapiro-Wilk", + "Kolmogorov-Smirnov (one-sample)" + ), + selected = "Shapiro-Wilk" + ) + ) + ), + forms = tagList( + verbatim_popup_ui("warning", "Show Warnings"), + verbatim_popup_ui("rcode", "Show R code") + ) +) + } diff --git a/man/table_with_settings.Rd b/man/table_with_settings.Rd index 88ea4e15..870a8ae9 100644 --- a/man/table_with_settings.Rd +++ b/man/table_with_settings.Rd @@ -4,7 +4,7 @@ \alias{table_with_settings} \alias{table_with_settings_ui} \alias{table_with_settings_srv} -\title{table_with_settings module} +\title{\code{table_with_settings} module} \usage{ table_with_settings_ui(id, ...) @@ -27,7 +27,8 @@ a mechanism to allow modules which call this module to show/hide the table_with_ A \code{shiny} module. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr +Module designed to create a \code{shiny} table output based on \code{rtable} object (\code{ElementaryTable} or \code{TableTree}) input. } \examples{ library(shiny) diff --git a/man/white_small_well.Rd b/man/white_small_well.Rd index 12fc1cfc..7be47559 100644 --- a/man/white_small_well.Rd +++ b/man/white_small_well.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/white_small_well.R \name{white_small_well} \alias{white_small_well} -\title{Adds Class Small Well and overflow-x property to HTML output element} +\title{Small well class for HTML} \usage{ white_small_well(...) } @@ -13,7 +13,8 @@ white_small_well(...) An HTML output element with class Small Well and overflow-x property } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}\cr +Adds Small Well class and overflow-x property to HTML output element. } \details{ \code{white_small_well} is intended to be used with \code{\link[shiny:htmlOutput]{shiny::uiOutput()}}.