## Other User Interface Options

- [`tabsetPanel()`](http://shiny.rstudio.com/gallery/tabsets.html) - make multiple different output views (i.e. a plot in one tab, a data table in another)
- [`helpText()`](http://shiny.rstudio.com/gallery/telephones-by-region.html) - create additional text to help users navigate your applet
- [`submitButton()`](http://shiny.rstudio.com/gallery/widgets.html) - only update outputs when this button is clicked
- [`conditionalPanel()`](http://shiny.rstudio.com/gallery/conditionalpanel-demo.html) - only show certain UI options when conditions are met (i.e. if a certain tab is open, or a certain input is selected)

<small>[resource](http://shiny.rstudio.com/gallery/widget-gallery.html)</small>

## Getting the shiny app to react: server

- the server function connects inputs to outputs
- render functions create outputs of different types

```{r, eval = FALSE}
server  <-  function(input, output) {
  # make output objects from inputs  
  
  output$hist <- renderPlot({
    # code for plot
  
  })
}
```


## Render functions

- `renderDataTable()` - outputs an interactive, sortable data table
- `renderPlot()` - output an R plot
- `renderPrint()` - output text from print() in R
- `renderTable()` - output an HTML table
- `renderText()` - output text from R
- `renderUI()` - output a custom part of the user interface
- `renderImage()` - print an image to the page
- `htmlOutput()` - output html elements

## Example `server` function

```{r, eval = FALSE}
server <- function(input, output) {
    output$hist <- renderPlot({
        dist <- rnorm(n = input$num)
        gg <- data.frame(dist) %>% 
          ggplot(aes(x = dist)) + geom_histogram(binwidth = 0.25) +
          xlim(c(-10,10))
        print(gg)
    })
}
```

Note the use of curly brackets `{` `}` in `renderPlot`.

The last statement in the code block must be the plot. 


## Your Turn  {data-background=#527a7a}

For the 01_Hello app: 

- expand on the server functionality to make the plot react to the input



## An example

```{r, eval=FALSE}
runApp("02_Reactivity", display.mode = "showcase")
```


## Your Turn {data-background=#527a7a}

Using your own data or the NYC crime data provided, create a simple Shiny app. 
Use the NYC_Emergency app as a starting point.

```{r, eval=FALSE}
runApp("03_NYC_Emergency")
```

- Ideas: 
    - Plot some aspect of the data with color based on another aspect of the data
    - Use `filter()` and `checkboxInput()` to plot user-selected subsets
    - Use `tabsetPanel()` to display different tables/plots
    - **Extra Challenging:** Can you make a map of NYC crime by location?
