Skip to content

nfultz/easyslider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easyslider: Easy sliders for shiny.

Quickly add UI components by aesthetic mapping

It can be frustrating to add a slider in shiny, which typically required changing code in three places: the uiOutput in ui.R, renderUI in server.R and also wiring it up to a plot by reading from input$thing. The name parameter has to match in all three places or the slider won't work.

Instead, we can build simple UIs more conviniently by generating the components from aesthetics. In your server function, pipe data through some filters, then generate plots and tables appropriately.

Example:

Pipe your data through a filter and use it in a plot:

 #server.R

 require(dplyr)
 require(ggplot2)

 library(shiny)
 library(easyslider)


 shinyServer(function(input, output) {

   df <- diamonds %>%
     slider2Filter(aes(depth)) %>%
     dropdownFilter(aes(clarity))

   output$distPlot <- renderPlot({
       df() %>% ggplot() + aes(x=carat, y=price, color=cut) + geom_point()
     })

 })

And a simple UI, which doesn't need to be updated as you change filters:

 #ui.R

 library(shiny)


 shinyUI(fluidPage(

   # Application title
   titlePanel("Easy Slider Diamond Demo"),

   # Sidebar with easyslider controls
   sidebarLayout(
     sidebarPanel(
       easySliderUIOutput()
     ),

     # Show a plot of the filtered data
     mainPanel(
       plotOutput("distPlot")
     )
   )

 ))


About

Easier sliders for Shiny

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages