regexSelect: Create a selectize list input control with regular expression...

Description Usage Arguments Value Examples

View source: R/regexSelect.R

Description

Create a selectize list that can be used to choose a single or multiple items from a list of values with extension for regular expression.

Usage

1
regexSelect(input, output, session, data)

Arguments

input

The input slot that will be used to access the value.

output

The output variable to read the list of values returned be regex query

session

The session of the shiny application

data

reactive element contains a character vector where matches are sought, or an object which can be coerced by as.character to a character vector

Value

reactive character vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
if(interactive()){
ui <- shiny::fluidPage(
regexSelectUI(id = "a", label = "Variable:",choices = names(iris)),
shiny::tableOutput("data")
)


ui.show <- shiny::fluidPage(
regexSelectUI(id = "a", label = "Variable:",choices = names(iris),checkbox.show = TRUE),
shiny::tableOutput("data")
)

server <- function(input, output, session) {
 curr_cols<-shiny::callModule(regexSelect, "a",shiny::reactive(names(iris)))
 
 shiny::observeEvent(curr_cols(),{
 cols_now<-curr_cols()
 if(length(cols_now)==0)  cols_now<-names(data())
 output$data <- shiny::renderTable({iris[,cols_now , drop = FALSE]}, rownames = TRUE)
 })
}

#do not show regex checkboxes
shiny::shinyApp(ui, server)

#show regex checkboxes
shiny::shinyApp(ui.show, server)
 }

Example output



regexSelect documentation built on May 1, 2019, 10:56 p.m.