Learn R Programming

shinyfilters (version 0.3.0)

filterInput: Create a shiny Input

Description

Selects and creates a shiny input based the type of object x and other arguments.

Usage

filterInput(x, ...)

Value

One of the following shiny inputs is returned, based on the type of object passed to x, and other specified arguments. See vignette("filter-input-catalog") for the full list of examples.

ValuexArguments
shiny::dateInputDate, POSIXtdefault
shiny::dateRangeInputDate, POSIXtrange = TRUE
shiny::numericInputnumericdefault
shiny::radioButtonscharacter, factor, list, logicalradio = TRUE
shiny::selectInputcharacter, factor, list, logicaldefault
shiny::selectizeInputcharacter, factor, list, logicalselectize = TRUE
shiny::sliderInputnumericslider = TRUE
shiny::textAreaInputcharactertextbox = TRUE, area = TRUE
shiny::textInputcharactertextbox = TRUE

Arguments

x

The object used to create the input.

...

Arguments used for input selection or passed to the selected input. See details.

Details

The following arguments passed to ... are supported:

area

(character). Logical. Controls whether to use shiny::textAreaInput (TRUE) or shiny::textInput (FALSE, default). Only applies when textbox is TRUE.

radio

(character, factor, list, logical). Logical. Controls whether to use shiny::radioButtons (TRUE) or a dropdown input (FALSE, default). For character vectors, radio only applies if textbox is FALSE, the default.

range

(Date, POSIXt). Logical. Controls whether to use shiny::dateRangeInput (TRUE) or shiny::dateInput (FALSE, default).

selectize

(character, factor, list, logical). Logical. Controls whether to use shiny::selectizeInput (TRUE) or shiny::selectInput (FALSE, default). For character vectors, selectize only applies if textbox is FALSE, the default.

slider

(numeric). Logical. Controls whether to use shiny::sliderInput (TRUE) or shiny::numericInput (FALSE, default).

textbox

(character). Logical. Controls whether to use a text input (TRUE) or a dropdown input (FALSE, default).

ns

An optional namespace created by shiny::NS(). Useful when using filterInput() on a data.frame inside a shiny module.

Remaining arguments passed to ... are passed to the args_filter_input() or the selected input function.

Examples

Run this code
if (FALSE) { # interactive()
library(shiny)

ui <- fluidPage(
	 sidebarLayout(
		 sidebarPanel(
			 # Create a filterInput() inside a shiny app:
			 filterInput(
				x = letters,
				inputId = "letter",
				label = "Pick a letter:"
			 )
		 ),
		 mainPanel(
			 textOutput("selected_letter")
		 )
	 )
)

server <- function(input, output, session) {
	 output$selected_letter <- renderText({
		 paste("You selected:", input$letter)
	 })
}

shinyApp(ui, server)
}

Run the code above in your browser using DataLab