Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(conflicted)
- library(tidyverse)
- library(scales)
- filter <- dplyr::filter
- # To make import easier, I exported my data using dput() and pasted the results here
- obit <-
- structure(
- list(
- Year = 1985:2019,
- Total = c(
- 141072L,
- 190698L,
- 257543L,
- 282117L,
- 347959L,
- 471336L,
- 566849L,
- 619844L,
- 733273L,
- 826277L,
- 929403L,
- 1036210L,
- 1176373L,
- 1271789L,
- 1411098L,
- 1557809L,
- 1744998L,
- 2070572L,
- 2378939L,
- 2640516L,
- 2828626L,
- 3058626L,
- 3193418L,
- 3360432L,
- 3162040L,
- 3417941L,
- 3610571L,
- 3605410L,
- 3539897L,
- 3300628L,
- 3198552L,
- 3106570L,
- 2988815L,
- 2640684L,
- 811030L
- ),
- Died = c(
- 107811L,
- 133630L,
- 184232L,
- 203949L,
- 261198L,
- 357171L,
- 432664L,
- 484774L,
- 573485L,
- 660214L,
- 723804L,
- 786384L,
- 873911L,
- 936788L,
- 1084051L,
- 1187872L,
- 1293795L,
- 1451134L,
- 1548716L,
- 1663590L,
- 1721344L,
- 1773371L,
- 1774388L,
- 1739529L,
- 1529231L,
- 1580080L,
- 1607773L,
- 1560059L,
- 1424419L,
- 1294834L,
- 1237948L,
- 1121436L,
- 1044591L,
- 885010L,
- 267344L
- ),
- Euphemism = c(
- 5414L,
- 6948L,
- 8749L,
- 10182L,
- 10291L,
- 14543L,
- 15328L,
- 17591L,
- 22792L,
- 33952L,
- 47690L,
- 65491L,
- 76433L,
- 89193L,
- 101662L,
- 126877L,
- 174956L,
- 236704L,
- 304509L,
- 362663L,
- 429321L,
- 550478L,
- 682362L,
- 840522L,
- 886338L,
- 1010024L,
- 1150420L,
- 1215321L,
- 1304262L,
- 1254868L,
- 1253941L,
- 1270894L,
- 1249445L,
- 1150418L,
- 359664L
- )
- ),
- class = c("spec_tbl_df",
- "tbl_df", "tbl", "data.frame"),
- row.names = c(NA, -35L),
- spec = structure(list(
- cols = list(
- year = structure(list(), class = c("collector_integer",
- "collector")),
- total = structure(list(), class = c("collector_integer",
- "collector")),
- died = structure(list(), class = c("collector_integer",
- "collector")),
- euphemism = structure(list(), class = c("collector_integer",
- "collector"))
- ),
- default = structure(list(), class = c("collector_guess",
- "collector")),
- skip = 1
- ), class = "col_spec")
- )
- # Now that the data's loaded, time for analysis
- # Gather the wide data into a longer format
- obit <- obit %>%
- gather("Category", "References",-Year,-Total) %>%
- mutate(Percent = References / Total)
- # ggplot time!
- ggplot(obit, aes(x = Year, y = Percent, color = Category)) +
- geom_point(size = 4) +
- geom_line(size = 2) +
- scale_y_continuous(labels = partial(scales::percent, accuracy = 1)) +
- labs(title = "Nobody dies anymore",
- caption = "Created by TrueBirch using NewsBank obituary database",
- subtitle = "Subtitle goes here. Subtitles are usually much longer than titles.") +
- theme(
- plot.subtitle = element_text(size = 17,
- hjust = 0.5),
- panel.grid.major = element_line(colour = "gray95"),
- panel.grid.minor = element_line(colour = NA),
- plot.title = element_text(size = 25,
- hjust = 0.5),
- panel.background = element_rect(fill = NA),
- axis.title = element_text(size = 12),
- legend.key = element_rect(fill = NA),
- legend.background = element_rect(fill = NA)
- ) + labs(subtitle = "Over the past 20 years, death announcements have mostly replaced the word \"died\" with euphemisms like \"passed\" or \"departed\"") + labs(
- y = "Percent of death announcements using the
- word \"died\" versus a euphemism",
- colour = NULL,
- subtitle = "Over the past 20 years, death announcements have mostly\nreplaced the word \"died\" with euphemisms like \"passed\" or \"departed\""
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement