---
title: "Data Visualization: Alluvial Plot"
output:
flexdashboard::flex_dashboard:
storyboard: true
orientation: columns
source_code: embed
vertical_layout: fill
theme: simplex
---
```{r setup, include=FALSE}
# PACKAGES / LIBRARIES:
library(flexdashboard)
library(tidyverse)
library(easyalluvial)
library(parcats)
library(ggthemr)
df_penguins <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-07-28/penguins.csv')
df_penguins <- df_penguins %>%
na.omit() %>%
select(Species = species,
Island = island,
Sex = sex,
`Bill Length` = bill_length_mm,
`Flipper Length` = flipper_length_mm,
`Body Mass` = body_mass_g)
```
Basic Alluvial Plot
=================================================================================================
```{r, out.width="100%", fig.width=10, fig.height=7}
palette = c('#8DD3C7', '#FDBF6F', "#FB9A99")
alluvial_wide( data = df_penguins,
max_variables = 6,
fill_by = 'first_variable',
col_vector_flow = palette,
col_vector_value = palette) +
labs(title = "Palmer Penguins",
subtitle = "Tidytuesday 2020, Week 31",
caption = "HH: High, High, MH: Medium High, M: Medium, ML: Medium Low, LL: Low Low") +
theme_dark()
```
Alluvial Plot with Marginal Histogram
=================================================================================================
```{r, out.width="100%", fig.width=10, fig.height=7}
x <- alluvial_wide( data = df_penguins,
max_variables = 6,
fill_by = 'first_variable',
col_vector_flow = palette,
col_vector_value = palette) +
theme_dark()
x %>% add_marginal_histograms(df_penguins)
```
Interactive Alluvial Plot
=================================================================================================
```{r, out.width="100%", fig.width=10, fig.height=7}
parcats(x, marginal_histograms = TRUE, data_input = df_penguins)
```