Column

Chart A

Column

Chart B

Chart C

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)

library(plotly)
```

```{r, include=FALSE}
data("rest_inspec") 

rest_inspection  =
    rest_inspec %>% 
    count(boro,cuisine_description, grade) %>% 
    drop_na()
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
x <- list(
  title = "cuisine"
)
y <- list(
  title = "number of grade A restaurant"
)

rest_inspection %>% 
  filter(grade == "A", n >= 1000) %>%
  group_by(cuisine_description, grade) %>% 
  mutate(count = sum(n),
         cuisine_description = replace(cuisine_description, cuisine_description == "Latin (Cuban, Dominican, Puerto Rican, South & Central American)", "Latin" )) %>% 
  distinct(cuisine_description, grade, count) %>% 
  mutate(cuisine_description = fct_reorder(cuisine_description, count)) %>% 
  plot_ly( x = ~cuisine_description, y = ~count, color = ~cuisine_description, 
          type = "bar", colors = "viridis") %>% 
  layout(xaxis = x, yaxis = y)

```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
rest_inspection %>% 
  filter(cuisine_description == "Café/Coffee/Tea",
         grade!="Not Yet Graded") %>% 
  plot_ly(x = ~grade, y = ~n, color = ~boro,type = "scatter", mode = "lines")
```

### Chart C

```{r}
rest_inspec %>% 
  select(score, boro) %>% 
  drop_na() %>% 
  subset(boro != "Missing") %>% 
  filter(score <= 60) %>% 
  mutate(boro = fct_reorder(boro, score)) %>% 
  plot_ly(x = ~boro, y = ~score, color = ~boro, colors = "viridis", type = "box")
```