R package to enable regular expression searches within a shiny selectize object.
::install_github('yonicd/regexSelect') devtools
require(shiny)
if(interactive()){
<- shiny::fluidPage(
ui regexSelectUI(id = "a", label = "Variable:",choices = names(iris)),
::tableOutput("data")
shiny
)
<- function(input, output, session) {
server <-callModule(regexSelect, "a",shiny::reactive(names(iris)))
curr_cols
observeEvent(curr_cols(),{
<-curr_cols()
cols_nowif(length(cols_now)==0) cols_now<-names(iris)
$data <- shiny::renderTable({iris[,cols_now , drop = FALSE]}, rownames = TRUE)
output
})
}
::shinyApp(ui, server)
shiny
}
library(ggplot2)
<- fluidPage(
ui selectInput('var','Choose Variable',
choices = names(diamonds)[sapply(diamonds,function(x) inherits(x,c('character','factor')))],
selected = 'clarity'),
uiOutput('regexchoose'),
plotOutput("data")
)
<- function(input, output, session) {
server
$regexchoose<-shiny::renderUI({
outputregexSelectUI(id = "a", label = input$var,choices = unique(diamonds[[input$var]]))
})
observeEvent(input$var,{
<-callModule(regexSelect, "a",shiny::reactive(unique(diamonds[[input$var]])))
curr_cols
observeEvent(curr_cols(),{
<-curr_cols()
cols_now$data <- shiny::renderPlot({
outputggplot(diamonds[diamonds[[input$var]]%in%cols_now,],aes_string(x='table',y='carat',colour=input$var))+geom_point()
})
})
})
}
shinyApp(ui, server)