GDPR Violations

Data manipulation, Interactive dashboard with shinymetrics and tidymetrics

Published

April 20, 2020

Notable topics: Data manipulation, Interactive dashboard with shinymetrics and tidymetrics

Recorded on: 2020-04-20

Timestamps by: Eric Fletcher

View code

Screencast

Timestamps

mdy
lubridate

Use the mdy function from the lubridate package to change the date variable from character class to date class.

rename
dplyr

Use the rename function from the dplyr package to rename variable in the dataset.

fct_reorder
forcats

Use the fct_reorder function from the forcats package to sort the geom_col in descending order.

fct_lumpcount
forcatsdplyr

Use the fct_lump function from the forcats package within count to lump together country names except for the 6 most frequent.

scale_x_continuous
ggplot2scales

Use the scale_x_continuous function from ggplot2 with the scales package to change the x-axis values to dollar format.

month
lubridate

Use the month and floor_date function from the lubridate package to get the month component from the date variable to count the total fines per month.

na_if
dplyr

Use the na_if function from the dplyr package to convert specific date value to NA.

fct_reorder
forcatsdplyr

Use the fct_reorder function from the forcats package to sort the stacked geom_col and legend labels in descending order.

dollar
scales

Use the dollar function from the scales package to convert the price variable into dollar format.

str_trunc
stringr

Use the str_trunc to shorten the summary string values to 140 characters.

separate_rows
tidyr

Use the separate_rows function from the tidyr package with a regular expression to separate the values in the article_violated variable with each matching group placed in its own row.

extract
tidyr

Use the extract function from the tidyr package with a regular expression to turn each matching group into a new column.

geom_jitter
ggplot2

Use the geom_jitter function from the ggplot2 package to add points to the horizontal box plot.

inner_join
dplyr

Use the inner_join function from the dplyr package to join together article_titles and separated_articles tables.

paste0
base R

Use the paste0 function from base R to concatenate article and article_title.

str_detect
stringr

Use the str_detect function from the stringr package to detect the presence of a pattern in a string.

group_bysummarizegeom_point
dplyrggplot2

Use the group_by and summarize functions from the dplyr package to aggregate fines that were issued to the same country on the same day allowing for size to be used in geom_point plot.

ggplot2
ggplot2

Use the scale_size_continuous function from the ggplot2 package to remove the size legend.

preview_metric
tidymetricsshinymetrics

Create an interactive dashboard using the shinymetrics and tidymetrics which is a tidy approach to business intelligence.

cross_by_dimensionscross_by_periodsuse_metrics_scaffoldcreate_metrics
tidyr

Use the cross_by_dimensions and cross_by_periods functions from the tidyr package which stacks an extra copy of the table for each dimension specified as an argument (country, article_title, type), replaces the value of the column with the word All and periods, and groups by all the columns. It acts as an extended group_by that allows complete summaries across each individual dimension and possible combinations.