html - Can you explain the magic of these shiny app example? -


here famous example of shinyapp on rstudio main page.

ui.r define 2 tabpanels in webpage.the first tab renders map, , second tab if selecting date full datetable according selectinput.

part of code:

 ...   tabpanel("data explorer",     fluidrow(       column(3,         selectinput("states", "states", c("all states"="", structure(state.abb, names=state.name), "washington, dc"="dc"), multiple=true)       ),       column(3,         conditionalpanel("input.states",           selectinput("cities", "cities", c("all cities"=""), multiple=true)         )       ),       column(3,         conditionalpanel("input.states",           selectinput("zipcodes", "zipcodes", c("all zipcodes"=""), multiple=true)         )       )     ),     fluidrow(       column(1,         numericinput("minscore", "min score", min=0, max=100, value=0)       ),       column(1,         numericinput("maxscore", "max score", min=0, max=100, value=100)       )     ),     hr(),     dt::datatableoutput("ziptable")   ), ... 
  1. i don't know line of code define variables, state.name , state.abb, used in 4th line of block above.

  2. the hierarchy select function quite simple here. why can work without choices in second , third selectinput function.

https://github.com/rstudio/shiny-examples/blob/master/063-superzip-example/ui.r

1

state.abb , state.name s datasets exists r see ?state.abb

2

there server.r

observe({     cities <- if (is.null(input$states)) character(0) else {       filter(cleantable, state %in% input$states) %>%         `$`('city') %>%         unique() %>%         sort()     }     stillselected <- isolate(input$cities[input$cities %in% cities])     updateselectinput(session, "cities", choices = cities,       selected = stillselected)   }) 

so choises changed dynamic serever side


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -