library(stringi)
library(htmltools)
library(googlesheets)
library(ggtext)
library(hrbrthemes)
library(svglite)
library(tidyverse)
gs_auth()
gs_key("1p-_GRo4YPW7m4QnjvErKD4U67t8-O6aDBlRjy9V8g8Y") %>%
gs_read(col_types = "cdcccccDc") -> edu_df
count(edu_df, year_public, incident_type) %>%
mutate(year_public = factor(year_public, 2016:2019)) %>%
mutate(incident_type = fct_reorder(incident_type, n, sum, .desc = TRUE)) %>%
mutate(fcol = ifelse(year_public == 2019, ft_cols$peach, ft_cols$slate)) %>%
ggplot(aes(year_public, n)) +
geom_col(width = 0.65, aes(fill = I(fcol))) +
geom_rect(
data = data.frame(
incident_type = ""
),
aes(x = -Inf, y = Inf, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf),
color = "white", fill = "white"
) +
geom_rich_text(
data = data.frame(
incident_type = "",
x = 0, y = 40,
lab = '<span style="font-size:14"><b>Immune or just lucky?</b></span><br/>Despite <span style="color:#bd0026;fill:#bd0026;"><b>rising</b></span> ransomware incident<br/>counts in businesses and municipalities,<br/>U.S. K-12 schools appear to be less<br/>impacted by these often devastating attacks.'
),
aes(x, y, label = lab), hjust = 0, label.size = 0, family = "Arial"
) +
scale_y_comma(limits = c(0, 84)) +
facet_wrap(~incident_type, scales = "free_x") +
labs(
x = NULL, y = NULL,
title = "Data Breaches Still More Prevalent Than Ransomware in U.S. K-12 Schools",
subtitle = "K-12 annual (reported) cyber incident count since 2016, ordered from most prevalent to least prevalent incident type.<br/><br/>Current year higlighted in <span style='color:#fba29d;'><b>pink</b></span>.",
caption = "Source (data): EdTech Strategies, LLC <https://k12cybersecure.com/map/>"
) +
theme_minimal(base_family = "Arial") +
theme(panel.grid.major.x = element_blank()) +
theme(panel.grid.minor.x = element_blank()) +
theme(panel.grid.major.y = element_line()) +
theme(panel.grid.minor.y = element_blank()) +
theme(panel.spacing = unit(32, "pt")) +
theme(strip.text = element_text(hjust = 0, size = 14, face = "bold")) +
theme(plot.margin = margin(32, 32, 32, 32, "pt")) +
theme(plot.title = element_text(family = "Arial", size = 18, face = "bold")) +
theme(plot.subtitle = element_markdown()) +
theme(plot.caption = element_text(hjust = 0)) -> gg
stringSVG(print(gg), width=800/72, height=550/72) %>%
stri_replace_first_fixed(
"https://k12cybersecure.com/map/",
'<a xlink:href="https://k12cybersecure.com/map/">https://k12cybersecure.com/map/</a>'
) %>%
stri_replace_first_fixed(
"rising",
'<a xlink:href="https://www.cnn.com/2019/05/10/politics/ransomware-attacks-us-cities/index.html">rising</a>'
) %>%
HTML()