mercredi 25 mai 2016

Can you explain the magic of these shiny app example?

Here is the famous example of shinyapp on Rstudio main page.

ui.R define two tabPanels in the webpage.The first tab renders a map, and the second tab if for selecting date from a full datetable according to the selectInput.

part of the 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 which line of code define the variables, state.name and state.abb, which is used in 4th line of the block above.

  2. The hierarchy select function is quite simple here. Why can it work without choices in the second and third selectInput function.

http://ift.tt/25g8QKK




Aucun commentaire:

Enregistrer un commentaire