library(tidyverse)
library(p8105.datasets)
library(plotly)
library(dplyr)
Load NYC restaurant inspection data.
data("rest_inspec")
rest_inspect_sample <-
rest_inspec |>
drop_na() |>
slice_sample(n = 500)
Generate plots for NYC restaurant inspection data.
bar_graph <-
rest_inspect_sample |>
count(grade) |>
mutate(grade = fct_reorder(grade, n)) |>
plot_ly(x = ~grade, y = ~n, color = ~grade, type = "bar")
box_chart <-
rest_inspect_sample |>
mutate(boro = fct_reorder(boro, score)) |>
plot_ly(y = ~score, color = ~boro, type = "box")
scatterplot <-
rest_inspect_sample |>
plot_ly(x = ~inspection_date, y = ~score, type = "scatter", mode = "markers",
color = ~critical_flag)