Chapter 9 Shiny Apps and RMarkdown

In this assignment, I am going to explore the nyc_dop_juvenile_rearrest_rate dataset to test my coding skills with shiny apps and RMarkdown.

9.1 Loading my libraries

library(shiny)
library(tidyverse)
library(nycOpenData)
library(DT)

9.2 Calling my data

Let’s bring the data for the assignment.

data_rr <- nyc_dop_juvenile_rearrest_rate(limit = 10000)
head(data_rr)
## # A tibble: 6 × 4
##   borough  month     year  rate 
##   <chr>    <chr>     <chr> <chr>
## 1 Citywide October   2025  4.7  
## 2 Citywide September 2025  4.9  
## 3 Citywide August    2025  4.1  
## 4 Citywide July      2025  4.7  
## 5 Citywide June      2025  4.7  
## 6 Citywide May       2025  4.4

9.3 Inputs and Outputs

You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. This demonstrates how a standard R plot can be made interactive by wrapping it in the Shiny renderPlot function. The selectInput and sliderInput functions create the input widgets used to drive the plot.

## Warning: In sliderInput(): `value` should be less than or equal to `max`
## (value = 2025, max = 2020).