---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source: embed
---
```{r setup, include=FALSE}
library(tidyverse)
library("p8105.datasets")
library(plotly)
library(flexdashboard)
```
```{r}
data("rest_inspec")
rest_inspec =
rest_inspec %>%
drop_na(score) %>%
separate(
inspection_date,
into = c("year", "month", "day")
) %>%
select(boro, critical_flag, cuisine_description, dba, year, month, day, score) %>%
filter(
boro == 'MANHATTAN',
year == '2017'
) %>%
group_by(cuisine_description) %>%
filter(n() > 500) %>%
ungroup()
rest_inspec[rest_inspec == 'Latin (Cuban, Dominican, Puerto Rican, South & Central American)'] <- 'Latin'
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
rest_inspec %>%
mutate(text_label = str_c("Name: ", dba, "\nMonth: ", month, "\nDay: ", day)) %>%
plot_ly(
x = ~cuisine_description, y = ~score, color = ~critical_flag, text = ~text_label,
alpha = .5, type = "scatter", mode = "markers", colors = "viridis")
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r}
rest_inspec %>%
mutate(cuisine_description = fct_reorder(cuisine_description, score)) %>%
plot_ly(
y = ~score, x = ~cuisine_description, color = ~cuisine_description,
type = "box", colors = "viridis")
```
### Chart C
```{r}
rest_inspec %>%
count(cuisine_description) %>%
mutate(cuisine_description = fct_reorder(cuisine_description, n)) %>%
plot_ly(
x = ~cuisine_description, y = ~n, color = ~cuisine_description,
type = "bar", colors = "viridis")
```