Last updated: 2021-09-15
Checks: 7 0
Knit directory: myTidyTuesday/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210907)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 92bc445. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: catboost_info/
Ignored: data/2021-09-08/
Ignored: data/acs_poverty.rds
Ignored: data/fmhpi.rds
Ignored: data/grainstocks.rds
Ignored: data/hike_data.rds
Ignored: data/us_states.rds
Ignored: data/us_states_hexgrid.geojson
Ignored: data/weatherstats_toronto_daily.csv
Untracked files:
Untracked: code/work list batch targets.R
Untracked: figure/
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/GDPRfines.Rmd
) and HTML (docs/GDPRfines.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 92bc445 | opus1993 | 2021-09-15 | add tweet attribution and new viridis color scheme |
Rmd | 02009d5 | opus1993 | 2021-09-15 | add tweet attribution and new viridis color scheme |
This week’s #TidyTuesday
dataset is on EU GDPR violations.
In addition, R version 4.0.0 Arbor Day was just released. I am re-installing packages as-required while going through projects like this one.
The R Studio team recently launched tidymodels.org
, a new central location with resources and documentation for tidymodels packages. Check out the official blog post for more details.
Julia Silge published a great blog post with another screencast demonstrating how to use tidymodels
. She includes a good video for folks getting started with tidymodels
.
Our modeling goal here is to understand what kind of GDPR violations are associated with higher fines in the #TidyTuesday dataset for this week. Before we start, what are the most common GDPR articles actually about? Roughly speaking:
Let’s get started by looking at the data on violations.
gdpr_raw <- readr::read_tsv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-04-21/gdpr_violations.tsv")
gdpr_raw %>%
head() %>%
knitr::kable("html") %>%
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = F,
fixed_thead = T
)
id | picture | name | price | authority | date | controller | article_violated | type | source | summary |
---|---|---|---|---|---|---|---|---|---|---|
1 | https://www.privacyaffairs.com/wp-content/uploads/2019/10/republic-of-poland.svg | Poland | 9380 | Polish National Personal Data Protection Office (UODO) | 10/18/2019 | Polish Mayor | Art. 28 GDPR | Non-compliance with lawful basis for data processing | https://uodo.gov.pl/decyzje/ZSPU.421.3.2019 | No data processing agreement has been concluded with the company whose servers contained the resources of the Public Information Bulletin (BIP) of the Municipal Office in Aleksandrów Kujawski. For this reason, a fine of 40.000 PLN (9400 EUR) was imposed on the mayor of the city. |
2 | https://www.privacyaffairs.com/wp-content/uploads/2019/10/romania.svg | Romania | 2500 | Romanian National Supervisory Authority for Personal Data Processing (ANSPDCP) | 10/17/2019 | UTTIS INDUSTRIES | Art. 12 GDPR|Art. 13 GDPR|Art. 5 (1) c) GDPR|Art. 6 GDPR | Information obligation non-compliance | https://www.dataprotection.ro/?page=A_patra_amenda&lang=ro | A controller was sanctioned because he had unlawfully processed the personal data (CNP), and images of employees obtained through the surveillance system. The disclosure of the CNP in a report for the ISCIR training in 2018 wasn’t legal, as per Art.6 GDPR. |
3 | https://www.privacyaffairs.com/wp-content/uploads/2019/10/spain.svg | Spain | 60000 | Spanish Data Protection Authority (AEPD) | 10/16/2019 | Xfera Moviles S.A. | Art. 5 GDPR|Art. 6 GDPR | Non-compliance with lawful basis for data processing | https://www.aepd.es/resoluciones/PS-00262-2019_ORI.pdf | The company had unlawfully processed the personal data despite the subject’s request to stop doing so. |
4 | https://www.privacyaffairs.com/wp-content/uploads/2019/10/spain.svg | Spain | 8000 | Spanish Data Protection Authority (AEPD) | 10/16/2019 | Iberdrola Clientes | Art. 31 GDPR | Failure to cooperate with supervisory authority | https://www.aepd.es/resoluciones/PS-00304-2019_ORI.pdf | Iberdrola Clientes violated Article 13 of the GDPR when it showed a complete lack of cooperation with the AEPD. The latter had requested Iberdrola Clientes to provide the necessary information needed to add a person to the solvency list. |
5 | https://www.privacyaffairs.com/wp-content/uploads/2019/10/romania.svg | Romania | 150000 | Romanian National Supervisory Authority for Personal Data Processing (ANSPDCP) | 10/09/2019 | Raiffeisen Bank SA | Art. 32 GDPR | Failure to implement sufficient measures to ensure information security | https://www.dataprotection.ro/?page=Comunicat_Presa_09_10_2019&lang=ro | Raiffeisen Bank Romania did not observe the necessary security measures required by the GDPR when it assessed the scores of individuals on the WhatsApp platform. The personal data was exchanged via WhatsApp. |
6 | https://www.privacyaffairs.com/wp-content/uploads/2019/10/romania.svg | Romania | 20000 | Romanian National Supervisory Authority for Personal Data Processing (ANSPDCP) | 10/09/2019 | Vreau Credit SRL | Art. 32 GDPR|Art. 33 GDPR | Failure to implement sufficient measures to ensure information security | https://www.dataprotection.ro/?page=Comunicat_Presa_09_10_2019&lang=ro | The Company sent personal information through the WhatsApp platform to Raiffeisen Bank in order to facilitate the assessment of personal scores. The results were returned on the same platform. |
How are the fines distributed?
gdpr_raw %>%
ggplot(aes(price + 1)) +
geom_histogram(fill = "midnightblue", alpha = 0.7, bins = 40) +
scale_x_log10(labels = scales::dollar_format(prefix = "€")) +
labs(
title = "EU General Data Protection Regulation 2016/679 (GDPR) Fines",
subtitle = "Scraped from https://www.privacyaffairs.com/gdpr-fines/",
x = "GDPR fine (EUR)", y = "Number of GDPR violations",
caption = "@Jim_Gruman | #TidyTuesday"
)
Some of the violations were fined zero EUR. Let’s make a one-article-per-row version of this dataset.
gdpr_tidy <- gdpr_raw %>%
transmute(id,
price,
country = name,
article_violated,
articles = str_extract_all(article_violated, "Art.[:digit:]+|Art. [:digit:]+")
) %>%
mutate(total_articles = map_int(articles, length)) %>%
unnest(articles) %>%
add_count(articles) %>%
filter(n > 10) %>%
select(-n)
gdpr_tidy %>%
head() %>%
knitr::kable("html") %>%
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = F, fixed_thead = T
)
id | price | country | article_violated | articles | total_articles |
---|---|---|---|---|---|
2 | 2500 | Romania | Art. 12 GDPR|Art. 13 GDPR|Art. 5 (1) c) GDPR|Art. 6 GDPR | Art. 13 | 4 |
2 | 2500 | Romania | Art. 12 GDPR|Art. 13 GDPR|Art. 5 (1) c) GDPR|Art. 6 GDPR | Art. 5 | 4 |
2 | 2500 | Romania | Art. 12 GDPR|Art. 13 GDPR|Art. 5 (1) c) GDPR|Art. 6 GDPR | Art. 6 | 4 |
3 | 60000 | Spain | Art. 5 GDPR|Art. 6 GDPR | Art. 5 | 2 |
3 | 60000 | Spain | Art. 5 GDPR|Art. 6 GDPR | Art. 6 | 2 |
5 | 150000 | Romania | Art. 32 GDPR | Art. 32 | 1 |
How are the fines distributed by article?
gdpr_tidy %>%
mutate(
articles = str_replace_all(articles, "Art. ", "Article "),
articles = fct_reorder(articles, price)
) %>%
ggplot(aes(articles, price + 1, color = articles, fill = articles)) +
geom_boxplot(alpha = 0.2, outlier.colour = NA, show.legend = FALSE) +
geom_quasirandom(show.legend = FALSE) +
scale_y_log10(labels = scales::dollar_format(prefix = "€")) +
labs(
x = NULL, y = "GDPR fine (EUR)",
title = "GDPR Fines Levied, by Article",
subtitle = "For 250 violations in 25 countries",
caption = "@Jim_Gruman | #TidyTuesday"
)
Now let’s create a dataset for predictive modeling.
gdpr_violations <- gdpr_tidy %>%
mutate(value = 1) %>%
select(-article_violated) %>%
pivot_wider(
names_from = articles, values_from = value,
values_fn = list(value = max), values_fill = list(value = 0)
) %>%
janitor::clean_names()
gdpr_violations %>%
head() %>%
knitr::kable("html") %>%
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = F, fixed_thead = T
)
id | price | country | total_articles | art_13 | art_5 | art_6 | art_32 | art_15 |
---|---|---|---|---|---|---|---|---|
2 | 2500 | Romania | 4 | 1 | 1 | 1 | 0 | 0 |
3 | 60000 | Spain | 2 | 0 | 1 | 1 | 0 | 0 |
5 | 150000 | Romania | 1 | 0 | 0 | 0 | 1 | 0 |
6 | 20000 | Romania | 2 | 0 | 0 | 0 | 1 | 0 |
7 | 200000 | Greece | 2 | 0 | 1 | 0 | 0 | 0 |
9 | 30000 | Spain | 2 | 0 | 1 | 1 | 0 | 0 |
Let’s preprocess our data to get it ready for modeling.
gdpr_rec <- recipe(price ~ ., data = gdpr_violations) %>%
update_role(id, new_role = "id") %>%
step_log(price, base = 10, offset = 1, skip = TRUE) %>%
step_other(country, other = "Other") %>%
step_dummy(all_nominal_predictors()) %>%
step_zv(all_predictors())
gdpr_prep <- prep(gdpr_rec)
gdpr_prep
Data Recipe
Inputs:
role #variables
id 1
outcome 1
predictor 7
Training data contained 219 data points and no missing data.
Operations:
Log transformation on price [trained]
Collapsing factor levels for country [trained]
Dummy variables from country [trained]
Zero variance filter removed no terms [trained]
Let’s walk through the steps in this recipe.
recipe()
what our model is going to be (using a formula here) and what data we are using.id
, since this variable is not a predictor or outcome but I would like to keep it in the data for convenience.price
, the amount of the fine)."Other"
category.Before using prep()
these steps have been defined but not actually run or implemented. The prep()
function is where everything gets evaluated.
Now it’s time to specify our model. I am using a workflow()
in this example for convenience; these are objects that can help you manage modeling pipelines more easily, with pieces that fit together like Lego blocks. This workflow()
contains both the recipe and the model (a straightforward Ordinary Least Squares linear regression).
gdpr_wf <- workflow() %>%
add_recipe(gdpr_rec) %>%
add_model(linear_reg() %>%
set_engine("lm"))
gdpr_wf
== Workflow ====================================================================
Preprocessor: Recipe
Model: linear_reg()
-- Preprocessor ----------------------------------------------------------------
4 Recipe Steps
* step_log()
* step_other()
* step_dummy()
* step_zv()
-- Model -----------------------------------------------------------------------
Linear Regression Model Specification (regression)
Computational engine: lm
You can fit()
a workflow, much like you can fit a model, and then you can pull out the fit object and tidy()
it to work with the estimates of the linear coefficients.
gdpr_fit <- gdpr_wf %>%
fit(data = gdpr_violations)
extract_fit_engine(gdpr_fit) %>%
tidy() %>%
arrange(desc(estimate))
# A tibble: 13 x 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 3.77 0.409 9.21 3.82e-17
2 total_articles 0.480 0.166 2.90 4.20e- 3
3 country_Spain 0.430 0.364 1.18 2.40e- 1
4 country_Other 0.234 0.355 0.660 5.10e- 1
5 country_Germany 0.0597 0.419 0.143 8.87e- 1
6 art_32 -0.153 0.315 -0.487 6.27e- 1
7 country_Hungary -0.155 0.479 -0.324 7.46e- 1
8 country_Romania -0.346 0.433 -0.799 4.25e- 1
9 art_5 -0.419 0.283 -1.48 1.40e- 1
10 art_6 -0.560 0.295 -1.90 5.91e- 2
11 country_Czech.Republic -0.650 0.467 -1.39 1.66e- 1
12 art_13 -0.763 0.407 -1.87 6.27e- 2
13 art_15 -1.57 0.465 -3.37 8.97e- 4
GDPR violations of more than one article have higher fines.
Lots of those coefficients have big p-values (for example, all the countries) but I think the best way to understand these results will be to visualize some predictions. You can predict on new data in tidymodels with either a model or a workflow()
.
Let’s create some example new data that we are interested in.
new_gdpr <- crossing(
country = "Other",
art_5 = 0:1,
art_6 = 0:1,
art_13 = 0:1,
art_15 = 0:1,
art_32 = 0:1
) %>%
mutate(
id = row_number(),
total_articles = art_5 + art_6 + art_13 + art_15 + art_32
)
new_gdpr %>%
head() %>%
knitr::kable("html") %>%
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = F, fixed_thead = T
)
country | art_5 | art_6 | art_13 | art_15 | art_32 | id | total_articles |
---|---|---|---|---|---|---|---|
Other | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Other | 0 | 0 | 0 | 0 | 1 | 2 | 1 |
Other | 0 | 0 | 0 | 1 | 0 | 3 | 1 |
Other | 0 | 0 | 0 | 1 | 1 | 4 | 2 |
Other | 0 | 0 | 1 | 0 | 0 | 5 | 1 |
Other | 0 | 0 | 1 | 0 | 1 | 6 | 2 |
Let’s find both the mean predictions and the confidence intervals.
mean_pred <- predict(gdpr_fit,
new_data = new_gdpr
)
conf_int_pred <- predict(gdpr_fit,
new_data = new_gdpr,
type = "conf_int"
)
gdpr_res <- new_gdpr %>%
bind_cols(mean_pred) %>%
bind_cols(conf_int_pred)
gdpr_res %>%
head() %>%
knitr::kable("html") %>%
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = F, fixed_thead = T
)
country | art_5 | art_6 | art_13 | art_15 | art_32 | id | total_articles | .pred | .pred_lower | .pred_upper |
---|---|---|---|---|---|---|---|---|---|---|
Other | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 4.000446 | 3.410428 | 4.590464 |
Other | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 4.326841 | 3.922444 | 4.731237 |
Other | 0 | 0 | 0 | 1 | 0 | 3 | 1 | 2.912359 | 2.245405 | 3.579314 |
Other | 0 | 0 | 0 | 1 | 1 | 4 | 2 | 3.238753 | 2.407347 | 4.070160 |
Other | 0 | 0 | 1 | 0 | 0 | 5 | 1 | 3.717506 | 2.992813 | 4.442199 |
Other | 0 | 0 | 1 | 0 | 1 | 6 | 2 | 4.043900 | 3.336772 | 4.751029 |
There are lots of things we can do wtih these results! For example, what are the predicted GDPR fines for violations of each article type (violating only one article)?
gdpr_res %>%
filter(total_articles == 1) %>%
pivot_longer(art_5:art_32) %>%
filter(value > 0) %>%
mutate(
name = str_replace_all(name, "art_", "Article "),
name = fct_reorder(name, .pred)
) %>%
ggplot(aes(name, 10^.pred, color = name)) +
geom_point(size = 3.5) +
geom_errorbar(aes(
ymin = 10^.pred_lower,
ymax = 10^.pred_upper
),
width = 0.2, alpha = 0.7
) +
labs(
x = NULL, y = "Increase in fine (EUR)",
title = "Predicted Fine for each Type of GDPR Article Violation",
subtitle = "Modeling based on 250 violations in 25 countries",
caption = "@Jim_Gruman | #TidyTuesday"
) +
scale_y_log10(labels = scales::dollar_format(prefix = "€", accuracy = 1))
We can see here that violations such as data breaches have higher fines on average than violations about rights of access.
# Get countries in dataset as a vector
gdpr_countries <- gdpr_raw %>%
distinct(name) %>%
pull()
# Get sf objects, filter by countries in dataset
countries_sf <- rnaturalearth::ne_countries(country = c(gdpr_countries, "Czechia"), scale = "large", returnclass = "sf") %>%
select(name, geometry) %>%
mutate(name = replace(name, name == "Czechia", "Czech Republic"))
# Group fines by country, merge with sf
countries_map <- gdpr_raw %>%
mutate(name = stringr::str_to_title(name)) %>%
group_by(name) %>%
mutate(
price_sum = sum(price),
price_label = case_when(
round(price_sum / 1e6) > 0 ~ paste0(round(price_sum / 1e6), "M"),
round(price_sum / 1e5) > 0 ~ paste0(round(price_sum / 1e6, 1), "M"),
round(price_sum / 1e3) > 0 ~ paste0(round(price_sum / 1e3), "K"),
price_sum > 0 ~ paste0(round(price_sum / 1e3, 1), " K"),
TRUE ~ "0"
)
) %>%
left_join(countries_sf) %>%
select(name, price_sum, price_label, geometry)
# Copied from https://developers.google.com/public-data/docs/canonical/countries_csv
centroids <- read_html("https://developers.google.com/public-data/docs/canonical/countries_csv") %>%
html_node("table") %>%
html_table()
# Dataset for red "arrows" (to draw with geom_polygon)
price_arrows <- countries_map %>%
select(name, price_sum, price_label) %>%
left_join(centroids) %>%
mutate(
arrow_x = list(c(longitude - 0.5, longitude, longitude + 0.5, longitude)),
arrow_y = list(c(latitude - 0.03, latitude, latitude - 0.03, latitude + price_sum / 1.5e6))
) %>%
unnest(c(arrow_x, arrow_y))
ggplot() +
# map
geom_sf(data = countries_map, aes(geometry = geometry), fill = "#EBE9E1", colour = "grey70", size = 0.25) +
# country name
geom_text(data = price_arrows, aes(x = longitude - 0.2, y = latitude - 0.4, label = name), check_overlap = TRUE, hjust = 0, vjust = 1, size = 3.5) +
# red price, over 10M
geom_text(data = subset(price_arrows, price_sum > 10e6), aes(x = longitude - 0.2, y = latitude - 2, label = price_label), check_overlap = TRUE, hjust = 0, vjust = 1, size = 3.5, colour = "#BA4E35") +
# black price, under 10M
geom_text(data = subset(price_arrows, price_sum < 10e6), aes(x = longitude - 0.2, y = latitude - 2, label = price_label), check_overlap = TRUE, hjust = 0, vjust = 1, size = 3.5, colour = "black") +
# red arrows
geom_polygon(data = price_arrows, aes(x = arrow_x, y = arrow_y, group = name), fill = "#BA4E35", colour = NA, alpha = 0.8) +
# title and caption
annotate("richtext",
x = -26, y = 80, hjust = 0, vjust = 1,
label = "**Total of GDPR fines by country**<br><span style = 'font-size:12pt'>Rounded to nearest million or thousand euro</span><br><span style = 'font-size:8pt'>Source: Privacy Affairs | Graphic: @Jim_Gruman</span>",
family = "Helvetica", size = 8, lineheight = 1.1, fill = NA, label.color = NA
) +
theme_void() +
theme(
plot.margin = unit(c(20, 20, 20, 20), "pt"),
plot.title = element_text(
color = "gray40",
size = 12, family = "Helvetica", face = "bold"
)
) +
coord_sf(xlim = c(-27.5, 37.5), ylim = c(32.5, 82.5), expand = FALSE) +
labs(x = NULL, y = NULL)
David Sjoberg built this incredible chart
tweetrmd::include_tweet("https://twitter.com/davsjob/status/1256293020791685123")
😱 I thought it might be a neat idea to combine a map, rank and a bar chart in one plot for #TidyTuesday. It was messy but fun.
— David Sjöberg (@davsjob) May 1, 2020
Code: https://t.co/IouFXdvYjf #rstats #ggplot #dataviz pic.twitter.com/wyHsUGpwKC
gdpr_df <- gdpr_raw %>%
group_by(name) %>%
summarise(
price = sum(price),
.groups = "drop"
)
sdf <- rnaturalearthdata::countries50 %>%
st_as_sf() %>%
st_make_valid() %>%
st_crop(xmin = -24, xmax = 31, ymin = 33, ymax = 73) %>%
filter(admin %in% gdpr_df$name) %>%
left_join(gdpr_df, by = c("admin" = "name")) %>%
mutate(
price_cap = price / pop_est,
admin = case_when(
admin == "United Kingdom" ~ "UK",
admin == "Czech Republic" ~ "Czech",
TRUE ~ admin
)
)
ranking <- st_geometry(sdf) %>%
st_point_on_surface() %>%
st_coordinates() %>%
as_tibble() %>%
bind_cols(tibble(
fine_cap = BBmisc::normalize(rank(sdf$price_cap), range = c(40.12161, 66.12161), method = "range"),
country = sdf$admin,
xend = 60,
x_axis_start = xend + 10,
fine_cap_x = BBmisc::normalize(sdf$price_cap, range = c(first(x_axis_start), 100), method = "range"),
val_txt = paste0(format(sdf$price_cap, digits = 0, nsmall = 2)),
val_txt2 = if_else(country == "Austria", paste0(val_txt, "€ per capita"), val_txt)
))
sdf <- sdf %>%
bind_cols(ranking %>% select(fine_cap))
ggplot() +
geom_sf(
data = sdf,
size = .3,
fill = "transparent",
color = "gray17"
) +
# Sigmoid from country to start of barchart
ggbump::geom_sigmoid(
data = ranking,
aes(
x = X,
y = Y,
xend = x_axis_start - .2,
yend = fine_cap,
group = country,
color = fine_cap
),
alpha = .6,
smooth = 10,
size = 1
) +
# Line from xstart to value
geom_segment(
data = ranking,
aes(
x = x_axis_start,
y = fine_cap,
xend = fine_cap_x,
yend = fine_cap,
color = fine_cap
),
alpha = .6,
size = 1,
lineend = "round"
) +
# Y axis - black line
geom_segment(
data = ranking,
aes(
x = x_axis_start,
y = 40,
xend = x_axis_start,
yend = 67
),
alpha = .6,
size = 1.3,
color = "black"
) +
# dot on centroid of country in map
geom_point(
data = ranking,
aes(x = X, y = Y, color = fine_cap),
size = 2
) +
# Country text
geom_text(
data = ranking,
aes(
x = x_axis_start - .5,
y = fine_cap,
label = country,
color = fine_cap
),
hjust = 1,
size = 2.5,
nudge_y = .5
) +
# Value text
geom_text(
data = ranking,
aes(
x = fine_cap_x,
y = fine_cap,
label = val_txt2,
color = fine_cap
),
hjust = 0,
size = 2,
nudge_x = .4
) +
coord_sf(clip = "off") +
scale_fill_viridis_c(option = "H") +
scale_color_viridis_c(option = "H") +
theme_void() +
labs(
title = "GDPR fines per capita",
subtitle = str_wrap(
"The General Data Protection Regulation (EU) 2016/679 (GDPR) is a regulation in EU law on data protection and privacy in the European Union (EU) and the European Economic Area (EEA).",
100
),
caption = "Source: TidyTuesday & Wikipedia"
) +
theme(
plot.margin = unit(c(0.5, 1, 0.5, 0.5), "cm"),
legend.position = "none",
plot.background = element_rect(fill = "black"),
plot.caption = element_text(color = "white"),
plot.title = element_text(
color = "white",
size = 16,
family = "Helvetica",
face = "bold"
),
plot.subtitle = element_text(color = "white", size = 8)
)
sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rvest_1.0.1 ggtext_0.1.1 sf_1.0-2
[4] rnaturalearth_0.1.0 ggbeeswarm_0.6.0 yardstick_0.0.8
[7] workflowsets_0.1.0 workflows_0.2.3 tune_0.1.6
[10] rsample_0.1.0 recipes_0.1.16 parsnip_0.1.7.900
[13] modeldata_0.1.1 infer_1.0.0 dials_0.0.9.9000
[16] scales_1.1.1 broom_0.7.9 tidymodels_0.1.3
[19] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7
[22] purrr_0.3.4 readr_2.0.1 tidyr_1.1.3
[25] tibble_3.1.4 ggplot2_3.3.5 tidyverse_1.3.1
[28] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] utf8_1.2.2 R.utils_2.10.1 tidyselect_1.1.1
[4] grid_4.1.1 pROC_1.18.0 munsell_0.5.0
[7] codetools_0.2-18 ragg_1.1.3 units_0.7-2
[10] future_1.22.1 withr_2.4.2 colorspace_2.0-2
[13] ggbump_0.1.0 highr_0.9 knitr_1.34
[16] rstudioapi_0.13 wk_0.5.0 Rttf2pt1_1.3.9
[19] listenv_0.8.0 labeling_0.4.2 git2r_0.28.0
[22] rnaturalearthdata_0.1.0 bit64_4.0.5 DiceDesign_1.9
[25] farver_2.1.0 rprojroot_2.0.2 parallelly_1.28.1
[28] vctrs_0.3.8 generics_0.1.0 ipred_0.9-11
[31] xfun_0.25 R6_2.5.1 markdown_1.1
[34] lhs_1.1.3 cachem_1.0.6 assertthat_0.2.1
[37] promises_1.2.0.1 vroom_1.5.4 nnet_7.3-16
[40] rgeos_0.5-7 beeswarm_0.4.0 gtable_0.3.0
[43] globals_0.14.0 timeDate_3043.102 rlang_0.4.11
[46] BBmisc_1.11 systemfonts_1.0.2 splines_4.1.1
[49] extrafontdb_1.0 selectr_0.4-2 checkmate_2.0.0
[52] s2_1.0.6 yaml_2.2.1 modelr_0.1.8
[55] backports_1.2.1 httpuv_1.6.2 gridtext_0.1.4
[58] extrafont_0.17 tools_4.1.1 lava_1.6.10
[61] ellipsis_0.3.2 kableExtra_1.3.4 jquerylib_0.1.4
[64] proxy_0.4-26 Rcpp_1.0.7 plyr_1.8.6
[67] classInt_0.4-3 rpart_4.1-15 viridis_0.6.1
[70] haven_2.4.3 hrbrthemes_0.8.0 fs_1.5.0
[73] here_1.0.1 furrr_0.2.3 magrittr_2.0.1
[76] reprex_2.0.1 GPfit_1.0-8 whisker_0.4
[79] R.cache_0.15.0 hms_1.1.0 rnaturalearthhires_0.2.0
[82] evaluate_0.14 readxl_1.3.1 gridExtra_2.3
[85] compiler_4.1.1 KernSmooth_2.23-20 crayon_1.4.1
[88] R.oo_1.24.0 htmltools_0.5.2 later_1.3.0
[91] tzdb_0.1.2 lubridate_1.7.10 DBI_1.1.1
[94] dbplyr_2.1.1 MASS_7.3-54 Matrix_1.3-4
[97] cli_3.0.1 R.methodsS3_1.8.1 parallel_4.1.1
[100] gower_0.2.2 pkgconfig_2.0.3 tweetrmd_0.0.9
[103] sp_1.4-5 xml2_1.3.2 foreach_1.5.1
[106] svglite_2.0.0 vipor_0.4.5 bslib_0.3.0
[109] hardhat_0.1.6 webshot_0.5.2 prodlim_2019.11.13
[112] snakecase_0.11.0 digest_0.6.27 janitor_2.1.0
[115] rmarkdown_2.10 cellranger_1.1.0 gdtools_0.2.3
[118] curl_4.3.2 lifecycle_1.0.0 jsonlite_1.7.2
[121] viridisLite_0.4.0 fansi_0.5.0 pillar_1.6.2
[124] lattice_0.20-44 fastmap_1.1.0 httr_1.4.2
[127] survival_3.2-11 glue_1.4.2 conflicted_1.0.4
[130] iterators_1.0.13 bit_4.0.4 class_7.3-19
[133] stringi_1.7.4 sass_0.4.0 rematch2_2.1.2
[136] textshaping_0.3.5 styler_1.5.1 e1071_1.7-8
[139] future.apply_1.8.1