-
Notifications
You must be signed in to change notification settings - Fork 0
/
flexdashboard_penguins.Rmd
105 lines (93 loc) · 2.48 KB
/
flexdashboard_penguins.Rmd
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
title: "Penguins flexdashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(include = FALSE, warning = FALSE)
library(readr)
library(dplyr)
library(ggplot2)
library(crosstalk)
library(flexdashboard)
library(purrr)
library(plotly)
library(tidyr)
library(palmerpenguins)
```
```{r prepare_data}
penguins_int <- penguins %>%
mutate(hover_text =
paste0("This ", sex,
" lives at ", island,
" and was measured in ", year))
shared.atc <- SharedData$new( penguins_int )
```
Column {.tabset}
-----------------------------------------------------------------------
### Beak measurements
```{r, include=TRUE, eval=TRUE, echo=FALSE}
penguins_int_plot1 <- ggplot(data = shared.atc) +
aes(x = bill_length_mm, y = bill_depth_mm, text = hover_text) +
geom_point(aes(color = species, shape = sex), size = 2) +
scale_color_manual(
values = c(
"darkorange",
"darkorchid",
"cyan4")) +
labs(title = "Penguin species differentation") +
xlab("bill length (mm)") +
ylab("bill depth (mm)") +
theme_minimal() +
theme(plot.title = element_text(face = "bold"))
bscols(widths = c(3, NA),
list(
filter_checkbox(
id = "sex_exclude",
label = "Filter by sex",
sharedData = shared.atc,
group = ~sex),
filter_slider(
id = "body_mass",
label = "Filter by body mass [g]",
sharedData = shared.atc,
column = ~body_mass_g
)
),
plotly::ggplotly(penguins_int_plot1, tooltip = "text", height = 600)
)
```
### Flipper length vs. body mass
```{r, include=TRUE, eval=TRUE, echo=FALSE}
penguins_int_plot2 <- ggplot(data = shared.atc) +
aes(x = flipper_length_mm, y = body_mass_g, text = hover_text) +
geom_point(aes(color = species, shape = sex), size = 2) +
scale_color_manual(
values = c(
"darkorange",
"darkorchid",
"cyan4")) +
labs(title = "Penguin species differentation") +
xlab("flipper length length (mm)") +
ylab("body mass (g)") +
theme_minimal() +
theme(plot.title = element_text(face = "bold"))
bscols(widths = c(3, NA),
list(
filter_checkbox(
id = "sex_exclude",
label = "Filter by sex",
sharedData = shared.atc,
group = ~sex),
filter_slider(
id = "beak_length",
label = "Filter by beak length [mm]",
sharedData = shared.atc,
column = ~bill_length_mm
)
),
plotly::ggplotly(penguins_int_plot2, tooltip = "text", height = 600)
)
```