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(p8105.datasets)
library(tidyverse)
library(plotly)
```

```{r}
data("rest_inspec")

rest_inspec = 
  rest_inspec |>
  filter(inspection_date >= '2017-01-01',
         boro != "Missing",
         grade %in% c("A","B","C")) |>
  select(c(cuisine_description, dba, inspection_date, score, zipcode, grade, boro, street)) |>
  drop_na(grade)
```


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

### Chart A

```{r}
rest_inspec |>
  filter(boro == "MANHATTAN",
         cuisine_description %in% c("American","Asian","Chinese","Spanish","Indian","Thai")) |>
  plot_ly(
    x = ~cuisine_description, 
    y = ~score, 
    color = ~grade, 
    alpha = 0.5, 
    text = ~dba,
    type = "violin", 
    mode = "markers")|>
  layout(title = "Restaurant Grade by Cuisine")
```

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

### Chart B

```{r}
rest_inspec |>
  plot_ly(
    x = ~boro,
    y = ~score,
    color = ~boro,
    type = "box",
    text = ~grade
  ) |>
  layout(title = "Inspection Score by Borough")
```

### Chart C

```{r}
rest_inspec |>
  filter(street == "BROADWAY",
         cuisine_description == "Pizza") |>
  distinct(dba, score) |>
  mutate(name = fct_reorder(dba, score)) |>
  plot_ly(
    x = ~name,
    y = ~score,
    type = "bar",
    text = ~name
  ) |>
  layout(title = "Pizza on Broadway")
```