The NYC restaurant inspection data was filtered to focus on Chinese restaurants with score over 60.
# select Chinese restaurant
rest_inspec =
rest_inspec %>%
janitor::clean_names() %>%
filter(
cuisine_description == "Chinese",
score > 60
) %>%
mutate(inspection_date = as.Date(inspection_date))
# plot score over time
rest_inspec %>%
group_by(boro) %>%
mutate(text_label = str_c("Resturants: ", dba, "\nScore: ", score)) %>%
plot_ly(
x = ~inspection_date, y = ~score, color = ~boro, text = ~text_label,
alpha = .5, type = "scatter", mode = "markers", colors = "plasma") %>%
layout(
xaxis = list(title = "Inspection Date"),
yaxis = list(title = "Score"),
title = "Inspection Date vs. Score"
) %>%
layout(legend = list(x = 0.05, y = 0.9))
# plot score for each neighborhood
rest_inspec %>%
group_by(boro) %>%
plot_ly(
y = ~score, x = ~boro, color = ~boro,
type = "box", colors = "plasma", showlegend = FALSE) %>%
layout(
xaxis = list(title = "Neighborhood"),
yaxis = list(title = "Score"),
title = "Neighborhood vs. Score"
)
# plot restaurant counts for each neighborhood
rest_inspec %>%
count(boro) %>%
mutate(boro = fct_reorder(boro, n)) %>%
plot_ly(
x = ~boro, y = ~n, color = ~boro,
type = "bar", colors = "plasma", showlegend = FALSE) %>%
layout(
xaxis = list(title = "Neighborhood"),
yaxis = list(title = "Count"),
title = "Neighborhood vs. Count of Restaurant"
)