Skip to content

Commit

Permalink
Fixing CRAN comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Oct 6, 2023
1 parent 6f2e8b9 commit 3210dd6
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 56 deletions.
32 changes: 22 additions & 10 deletions R/get_dt_rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,33 @@
#' @name get_dt_rows
#'
#' @examples
#' \dontrun{
#' library(shiny)
#' # in Shiny UI function
#' tagList(
#' get_dt_rows(ns("data_table"), ns("dt_rows")),
#' ...
#' )
#' ui <- function(id) {
#' ns <- NS(id)
#' tagList(
#' DT::DTOutput(ns("data_table")),
#' get_dt_rows(ns("data_table"), ns("dt_rows"))
#' )
#' }
#'
#' # use the input$dt_rows in the Shiny Server function
#' if (!is.null(input$dt_rows)) {
#' dt_args$options$pageLength <- input$dt_rows
#' } # nolint
#' do.call(DT::datatable, dt_args)
#' server <- function(id) {
#' moduleServer(id, function(input, output, session) {
#' output$data_table <- DT::renderDataTable(
#' {
#' iris
#' },
#' options = list(pageLength = input$dt_rows)
#' )
#' })
#' }
#'
#' if (interactive()) {
#' shinyApp(
#' ui = ui("my_table_module"),
#' server = function(input, output, session) server("my_table_module")
#' )
#' }
#' @export
get_dt_rows <- function(dt_name, dt_rows) {
tags$head(
Expand Down
7 changes: 7 additions & 0 deletions R/optionalInput.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#' @param width (`character(1)`)\cr
#' The width of the input passed to `pickerInput` e.g. `'auto'`, `'fit'`, `'100px'` or `'75%'`
#'
#' @return (`shiny.tag`) HTML tag with `pickerInput` widget and
#' non-interactive element listing selected values.
#'
#' @export
#'
#' @examples
Expand Down Expand Up @@ -471,6 +474,8 @@ extract_raw_choices <- function(choices, sep) {
#' an object of class `shiny.tag`. E.g. an object returned by [shiny::helpText()]
#' @param ... optional arguments to `sliderInput`
#'
#' @return (`shiny.tag`) HTML tag with `sliderInput` widget.
#'
#' @export
#'
#' @examples
Expand Down Expand Up @@ -532,6 +537,8 @@ optionalSliderInput <- function(inputId, label, min, max, value, label_help = NU
#' Otherwise, if it is of length three the three elements will map to `value`, `min` and `max` of
#' the [optionalSliderInput()] function.
#'
#' @return (`shiny.tag`) HTML tag with range `sliderInput` widget.
#'
#' @export
#'
#' @examples
Expand Down
37 changes: 26 additions & 11 deletions R/plot_with_settings.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#' UI part of plot-with-settings module
#'
#' @description `r lifecycle::badge("stable")`
#' @rdname plot_with_settings
#' @export
#'
#' @param id (\code{character}) module ID
plot_with_settings_ui <- function(id) {
checkmate::assert_string(id)

Expand Down Expand Up @@ -62,12 +58,16 @@ plot_with_settings_ui <- function(id) {
)
}

#' Server part of plot-with-settings module
#' Plot-with-settings module
#'
#' @rdname plot_with_settings
#' @description `r lifecycle::badge("stable")`
#' Universal module for plots with settings for height, width, and download.
#'
#' @export
#'
#' @inheritParams shiny::moduleServer
#'
#' @param plot_r (`reactive` or `function`)\cr
#' `reactive` expression or a simple `function` to draw a plot.
#' A simple `function` is needed e.g. for base plots like `plot(1)` as the output can not be caught when downloading.
Expand Down Expand Up @@ -107,10 +107,9 @@ plot_with_settings_ui <- function(id) {
#' If an invalid value is set then the default value is used and a warning is outputted to the console.
#'
#' @examples
#' \dontrun{
#' # Example using a reactive as input to plot_r
#' library(shiny)
#' shinyApp(
#' app1 <- shinyApp(
#' ui = fluidPage(
#' plot_with_settings_ui(
#' id = "plot_with_settings"
Expand All @@ -130,8 +129,12 @@ plot_with_settings_ui <- function(id) {
#' }
#' )
#'
#' if (interactive()) {
#' runApp(app1)
#' }
#'
#' # Example using a function as input to plot_r
#' shinyApp(
#' app2 <- shinyApp(
#' ui = fluidPage(
#' radioButtons("download_option", "Select the Option", list("ggplot", "trellis", "grob", "base")),
#' plot_with_settings_ui(
Expand Down Expand Up @@ -167,8 +170,12 @@ plot_with_settings_ui <- function(id) {
#' }
#' )
#'
#' if (interactive()) {
#' runApp(app2)
#' }
#'
#' # Example with brushing/hovering/clicking/double-clicking
#' shinyApp(
#' app3 <- shinyApp(
#' ui = fluidPage(
#' plot_with_settings_ui(
#' id = "plot_with_settings"
Expand Down Expand Up @@ -202,10 +209,14 @@ plot_with_settings_ui <- function(id) {
#' }
#' )
#'
#' if (interactive()) {
#' runApp(app3)
#' }
#'
#' # Example which allows module to be hidden/shown
#' library("shinyjs")
#'
#' shinyApp(
#' app4 <- shinyApp(
#' ui = fluidPage(
#' useShinyjs(),
#' actionButton("button", "Show/Hide"),
Expand All @@ -229,7 +240,11 @@ plot_with_settings_ui <- function(id) {
#' )
#' }
#' )
#'
#' if (interactive()) {
#' runApp(app4)
#' }
#'
plot_with_settings_srv <- function(id,
plot_r,
height = c(600, 200, 2000),
Expand Down
5 changes: 3 additions & 2 deletions R/table_with_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ table_with_settings_ui <- function(id, ...) {
#' @export
#'
#' @examples
#' \dontrun{
#' library(shiny)
#' library(rtables)
#' library(magrittr)
#' shinyApp(
#' app <- shinyApp(
#' ui = fluidPage(
#' table_with_settings_ui(
#' id = "table_with_settings"
Expand All @@ -69,6 +68,8 @@ table_with_settings_ui <- function(id, ...) {
#' table_with_settings_srv(id = "table_with_settings", table_r = table_r)
#' }
#' )
#' if (interactive()) {
#' runApp(app)
#' }
#'
table_with_settings_srv <- function(id, table_r, show_hide_signal = reactive(TRUE)) {
Expand Down
32 changes: 22 additions & 10 deletions man/get_dt_rows.Rd

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

4 changes: 4 additions & 0 deletions man/optionalSelectInput.Rd

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

3 changes: 3 additions & 0 deletions man/optionalSliderInput.Rd

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

3 changes: 3 additions & 0 deletions man/optionalSliderInputValMinMax.Rd

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

33 changes: 26 additions & 7 deletions man/plot_with_settings_srv.Rd → man/plot_with_settings.Rd

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

14 changes: 0 additions & 14 deletions man/plot_with_settings_ui.Rd

This file was deleted.

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

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

0 comments on commit 3210dd6

Please sign in to comment.