-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflex dashboard.Rmd
More file actions
67 lines (52 loc) · 1.34 KB
/
Copy pathflex dashboard.Rmd
File metadata and controls
67 lines (52 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: "dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(viridis)
library(p8105.datasets)
library(plotly)
```{r}
set.seed(1)
data(nyc_airbnb)
nyc_airbnb =
nyc_airbnb %>%
mutate(rating = review_scores_location / 2) %>%
select(
neighbourhood_group, neighbourhood, rating, price, room_type, lat, long) %>%
filter(
!is.na(rating), neighbourhood_group == "Manhattan", room_type == "Entire home/apt", price %in% 100:500) %>%
sample_n(5000)
```
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
nyc_airbnb %>%
plot_ly(x = ~lat, y = ~long, type = "scatter", mode = "markers",
color = ~price, alpha = 0.5)
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r}
nyc_airbnb %>%
mutate(neighbourhood = fct_reorder(neighbourhood, price)) %>%
plot_ly(y = ~price, color = ~neighbourhood, type = "box",
colors = "Set2")
```
### Chart C
```{r}
nyc_airbnb %>%
count(neighbourhood) %>%
mutate(neighbourhood = fct_reorder(neighbourhood, n)) %>%
plot_ly(x = ~neighbourhood, y = ~n, type = "bar")
```