add bullets in details for output return value (update corresponding example)

This commit is contained in:
Barret Schloerke
2018-06-08 10:51:37 -04:00
parent 97d490cfb4
commit b3690e8680
2 changed files with 36 additions and 18 deletions

View File

@@ -220,15 +220,22 @@ selectizeIt <- function(inputId, select, options, nonempty = FALSE) {
#' Create a select list input control from a data.frame
#' Select variables from a data frame
#'
#' Create a select list that can be used to choose a single or multiple items
#' from the column names of a data frame.
#'
#' The resulting output value will be returned as a symbol or a list of symbols
#' given the \code{multiple} is \code{FALSE} or \code{TRUE} respectively. With
#' \code{multiple} set to \code{FALSE}, the corresponding output should be used with \code{!!} within tidy evaluation. With
#' \code{multiple} set to \code{TRUE}, the corresponding output should be used with \code{!!!} within tidy evaluation.
#' The resulting output value will be returned as:
#' \itemize{
#' \item a symbol if \code{multiple = FALSE}. The output result should be
#' used with rlang's \code{\link[rlang]{!!}}. For example,
#' \code{ggplot2::aes(!!input$variable)}.
#' \item a list of symbols if \code{multiple = TRUE}. The output result
#' should be used with rlang's \code{\link[rlang]{!!!}} to expand
#' the symbol list as individual arguments. For example,
#' \code{dplyr::select(mtcars, !!!input$vars)} which is
#' equivalent to \code{dplyr::select(mtcars, !!input$vars[[1]], !!input$vars[[2]], ..., !!input$vars[[length(input$vars)]])}.
#' }
#'
#' By default, \code{varSelectInput()} and \code{selectizeInput()} use the
#' JavaScript library \pkg{selectize.js}
@@ -247,6 +254,8 @@ selectizeIt <- function(inputId, select, options, nonempty = FALSE) {
#' ## Only run examples in interactive R sessions
#' if (interactive()) {
#'
#' library(ggplot2)
#'
#' # single selection
#' shinyApp(
#' ui = fluidPage(
@@ -255,7 +264,7 @@ selectizeIt <- function(inputId, select, options, nonempty = FALSE) {
#' ),
#' server = function(input, output) {
#' output$data <- renderPlot({
#' ggplot2::qplot(!!input$variable, data = mtcars)
#' ggplot(mtcars, aes(!!input$variable)) + geom_histogram()
#' })
#' }
#' )
@@ -265,13 +274,13 @@ selectizeIt <- function(inputId, select, options, nonempty = FALSE) {
#' \dontrun{
#' shinyApp(
#' ui = fluidPage(
#' varSelectInput("variable", "Variable:", mtcars, multiple = TRUE),
#' varSelectInput("variables", "Variable:", mtcars, multiple = TRUE),
#' tableOutput("data")
#' ),
#' server = function(input, output) {
#' output$data <- renderTable({
#' if (length(input$variable) == 0) return(mtcars)
#' mtcars %>% dplyr::select(!!!input$variable)
#' if (length(input$variables) == 0) return(mtcars)
#' mtcars %>% dplyr::select(!!!input$variables)
#' }, rownames = TRUE)
#' }
#' )}