Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

149 revise documentation #226

Merged
merged 18 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions R/get_dt_rows.R
Original file line number Diff line number Diff line change
@@ -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
#'
Expand Down
2 changes: 1 addition & 1 deletion R/optionalInput.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
64 changes: 61 additions & 3 deletions R/panel_group.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -35,9 +73,9 @@ panel_group <- function(..., id = NULL) {
}

#' Panel widget
m7pr marked this conversation as resolved.
Show resolved Hide resolved
#' @md
#'
#' @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
Expand All @@ -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")))
Expand Down
36 changes: 30 additions & 6 deletions R/plot_with_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ plot_with_settings_ui <- function(id) {
#' Plot-with-settings module
#'
m7pr marked this conversation as resolved.
Show resolved Hide resolved
#' @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
Expand Down Expand Up @@ -596,15 +596,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.
Expand Down
34 changes: 30 additions & 4 deletions R/standard_layout.R
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,6 +19,32 @@
#'
#' @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(
#' teal.reporter::simple_reporter_ui("simple_reporter"),
#' 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,
Expand Down
5 changes: 3 additions & 2 deletions R/table_with_settings.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 3 additions & 2 deletions R/white_small_well.R
Original file line number Diff line number Diff line change
@@ -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()].
Expand Down
34 changes: 29 additions & 5 deletions man/clean_brushedPoints.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/get_dt_rows.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/optionalSliderInput.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 40 additions & 1 deletion man/panel_group.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion man/panel_item.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/plot_with_settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading