Column

Chart A

Column

Chart B

Chart C

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
    code_folding: hide
    theme: journal
---

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

```

```{r include = FALSE}
data("rest_inspec")
rest_inspec = 
  rest_inspec %>%
  janitor::clean_names() %>% 
  filter(
    cuisine_description == "Chinese",
    score > 60
  ) %>%
  mutate(inspection_date = as.Date(inspection_date))
```

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

### Chart A

```{r}
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))
```


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

### Chart B

```{r}
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"
  )
```

### Chart C

```{r}
rest_inspec %>%
  count(boro) %>%
  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"
  )
```