---
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 select data}
data("rest_inspec")
rest_inspec =
rest_inspec %>%
mutate(boro = str_to_title(boro)) %>%
filter(grade %in% c("A", "B", "C"), boro == "Manhattan") %>%
relocate(boro) %>%
sample_n(10000) %>%
view
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r scatterplot}
rest_inspec %>%
mutate(text_label = str_c("Score: ", score, "\nGrade: ", grade)) %>%
plot_ly(
x = ~inspection_date, y = ~score, type = "scatter", mode = "markers",
color = ~grade, text = ~text_label, alpha = 0.5)
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r boxplot}
rest_inspec %>%
plot_ly(y = ~score, color = ~cuisine_description, type = "box", colors = "plasma", showlegend = FALSE)
```
### Chart C
```{r barchart}
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 = "plasma", showlegend = FALSE)
```