brianhaas19

Women of 2020 (Tidy Tuesday 2020-12-08)

Dec 13th, 2020 (edited)
1,231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###################################################################################################
  2. # Women of 2020 - Word clouds of The BBC's 100 Women of 2020.
  3. # Created by: reddit.com/user/brianhaas19
  4.  
  5. # Notes: This code is a bit hacky, particularly the section for cleaning the tokens. Using functions to clean up
  6. # the tokens wasn't producing a nice result so I ended up going with manual cleaning. For a larger data set
  7. # this would be unfeasible and an automatic process would be required.
  8. # Also creating the four plots manually is inefficient. If I spent more time on this I would try to assemble them
  9. # with a loop or purrr::map() function.
  10.  
  11. # Link to data
  12. # https://github.com/rfordatascience/tidytuesday/blob/master/data/2020/2020-12-08
  13.  
  14. # Setup
  15. library(tidyverse)
  16. library(scales)
  17. library(patchwork)
  18. library(tidytext)
  19. library(SnowballC)
  20. library(ggwordcloud)
  21. library(cowplot)
  22. library(magick)
  23. theme_set(theme_minimal())
  24.  
  25. # Colors (mostly taken from the BBC article)
  26. light_grey <- "grey70"
  27. dark_grey <- "#404040"
  28. colors = c("Knowledge" = "#5AC2DE",
  29.            "Leadership" = "#EE741C",
  30.            "Creativity" = "#D04592",
  31.            "Identity" = "#34AA4D")
  32. colors_df <- data.frame(
  33.   category = names(colors),
  34.   color = colors
  35. )
  36.  
  37. # Load data
  38. ### Read in raw data:
  39. women <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-12-08/women.csv')
  40.  
  41. # Clean data
  42. ### Get tokens from raw data and remove stop words:
  43. word_count_raw <- unnest_tokens(women, word, description) %>% # word is the output column, description is the input column
  44.   anti_join(get_stopwords(), by = "word") %>%
  45.   filter(category != "All") %>%
  46.   group_by(category) %>%
  47.   count(word)
  48.  
  49. ### Clean up tokens:
  50. word_count_raw$word[word_count_raw$word %>% str_detect("^\\d*$")] <- NA_character_
  51. word_count_raw$word[word_count_raw$word == "5,000"] <- NA_character_
  52. word_count_raw$word[word_count_raw$word == "activists"] <- "activist"
  53. word_count_raw$word[word_count_raw$word == "accessible"] <- "access"
  54. word_count_raw$word[word_count_raw$word == "accusations"] <- "accused"
  55. word_count_raw$word[word_count_raw$word == "actresses"] <- "actress"
  56. word_count_raw$word[word_count_raw$word == "advance"] <- "advancing"
  57. word_count_raw$word[word_count_raw$word == "advanced"] <- "advancing"
  58. word_count_raw$word[word_count_raw$word == "advocate"] <- "advocacy"
  59. word_count_raw$word[word_count_raw$word == "advocating"] <- "advocacy"
  60. word_count_raw$word[word_count_raw$word == "afghan"] <- "afghanistan"
  61. word_count_raw$word[word_count_raw$word == "afghanistan’s"] <- "afghanistan"
  62. word_count_raw$word[word_count_raw$word == "african"] <- "africa"
  63. word_count_raw$word[word_count_raw$word == "afrika"] <- "africa"
  64. word_count_raw$word[word_count_raw$word == "afrika"] <- "africa"
  65. word_count_raw$word[word_count_raw$word == "ageing"] <- "age"
  66. word_count_raw$word[word_count_raw$word == "aim"] <- "aims"
  67. word_count_raw$word[word_count_raw$word == "also"] <- NA_character_
  68. word_count_raw$word[word_count_raw$word == "american"] <- "america"
  69. word_count_raw$word[word_count_raw$word == "americas"] <- "america"
  70. word_count_raw$word[word_count_raw$word == "archaeological"] <- "archaeology"
  71. word_count_raw$word[word_count_raw$word == "argentine"] <- "argentinian"
  72. word_count_raw$word[word_count_raw$word == "arts"] <- "art"
  73. word_count_raw$word[word_count_raw$word == "artist"] <- "art"
  74. word_count_raw$word[word_count_raw$word == "artists"] <- "art"
  75. word_count_raw$word[word_count_raw$word == "asian"] <- "asia"
  76. word_count_raw$word[word_count_raw$word == "became"] <- "becoming"
  77. word_count_raw$word[word_count_raw$word == "biological"] <- "biology"
  78. word_count_raw$word[word_count_raw$word == "book"] <- "books"
  79. word_count_raw$word[word_count_raw$word == "breweries"] <- "brewing"
  80. word_count_raw$word[word_count_raw$word == "built"] <- "building"
  81. word_count_raw$word[word_count_raw$word == "campaigns"] <- "campaign"
  82. word_count_raw$word[word_count_raw$word == "centre"] <- "center"
  83. word_count_raw$word[word_count_raw$word == "centres"] <- "center"
  84. word_count_raw$word[word_count_raw$word == "changing"] <- "change"
  85. word_count_raw$word[word_count_raw$word == "child"] <- "children"
  86. word_count_raw$word[word_count_raw$word == "children's"] <- "children"
  87. word_count_raw$word[word_count_raw$word == "children’s"] <- "children"
  88. word_count_raw$word[word_count_raw$word == "chilean"] <- "chile"
  89. word_count_raw$word[word_count_raw$word == "club's"] <- "club"
  90. word_count_raw$word[word_count_raw$word == "collaborates"] <- "collaborate"
  91. word_count_raw$word[word_count_raw$word == "collaborated"] <- "collaborate"
  92. word_count_raw$word[word_count_raw$word == "come"] <- "coming"
  93. word_count_raw$word[word_count_raw$word == "communicator"] <- "communicate"
  94. word_count_raw$word[word_count_raw$word == "communities"] <- "community"
  95. word_count_raw$word[word_count_raw$word == "conflicts"] <- "conflict"
  96. word_count_raw$word[word_count_raw$word == "contributed"] <- "contribution"
  97. word_count_raw$word[word_count_raw$word == "coronavirus"] <- "covid"
  98. word_count_raw$word[word_count_raw$word == "countries"] <- "country"
  99. word_count_raw$word[word_count_raw$word == "country’s"] <- "collaborate"
  100. word_count_raw$word[word_count_raw$word == "creating"] <- "create"
  101. word_count_raw$word[word_count_raw$word == "creator"] <- "create"
  102. word_count_raw$word[word_count_raw$word == "culturally"] <- "culture"
  103. word_count_raw$word[word_count_raw$word == "cultural"] <- "culture"
  104. word_count_raw$word[word_count_raw$word == "currently"] <- "current"
  105. word_count_raw$word[word_count_raw$word == "debates"] <- "debate"
  106. word_count_raw$word[word_count_raw$word == "defending"] <- "defender"
  107. word_count_raw$word[word_count_raw$word == "democratic"] <- "democracy"
  108. word_count_raw$word[word_count_raw$word == "democratic"] <- "democracy"
  109. word_count_raw$word[word_count_raw$word == "describes"] <- "describe"
  110. word_count_raw$word[word_count_raw$word == "described"] <- "describe"
  111. word_count_raw$word[word_count_raw$word == "developing"] <- "develope"
  112. word_count_raw$word[word_count_raw$word == "development"] <- "develope"
  113. word_count_raw$word[word_count_raw$word == "directed"] <- "director"
  114. word_count_raw$word[word_count_raw$word == "directing"] <- "director"
  115. word_count_raw$word[word_count_raw$word == "disabilities"] <- "disability"
  116. word_count_raw$word[word_count_raw$word == "disabled"] <- "disability"
  117. word_count_raw$word[word_count_raw$word == "diseases"] <- "disease"
  118. word_count_raw$word[word_count_raw$word == "documents"] <- "documentary"
  119. word_count_raw$word[word_count_raw$word == "documenting"] <- "documentary"
  120. word_count_raw$word[word_count_raw$word == "dr"] <- "DR"
  121. word_count_raw$word[word_count_raw$word == "educating"] <- "education"
  122. word_count_raw$word[word_count_raw$word == "educator"] <- "education"
  123. word_count_raw$word[word_count_raw$word == "empower"] <- "empowerment"
  124. word_count_raw$word[word_count_raw$word == "empowered"] <- "empowerment"
  125. word_count_raw$word[word_count_raw$word == "engineer"] <- "engineering"
  126. word_count_raw$word[word_count_raw$word == "entrepreneur"] <- "entrepreneurship"
  127. word_count_raw$word[word_count_raw$word == "environmental"] <- "environment"
  128. word_count_raw$word[word_count_raw$word == "ethiopian"] <- "ethiopia"
  129. word_count_raw$word[word_count_raw$word == "experienced"] <- "experience"
  130. word_count_raw$word[word_count_raw$word == "experiences"] <- "experience"
  131. word_count_raw$word[word_count_raw$word == "eyes"] <- "eye"
  132. word_count_raw$word[word_count_raw$word == "feminists"] <- "feminist"
  133. word_count_raw$word[word_count_raw$word == "festivals"] <- "festival"
  134. word_count_raw$word[word_count_raw$word == "films"] <- "film"
  135. word_count_raw$word[word_count_raw$word == "focusing"] <- "focus"
  136. word_count_raw$word[word_count_raw$word == "focuses"] <- "focus"
  137. word_count_raw$word[word_count_raw$word == "footballer"] <- "football"
  138. word_count_raw$word[word_count_raw$word == "forces"] <- "force"
  139. word_count_raw$word[word_count_raw$word == "formerly"] <- "former"
  140. word_count_raw$word[word_count_raw$word == "found"] <- "founder"
  141. word_count_raw$word[word_count_raw$word == "founded"] <- "founder"
  142. word_count_raw$word[word_count_raw$word == "founders"] <- "founder"
  143. word_count_raw$word[word_count_raw$word == "girl"] <- "girls"
  144. word_count_raw$word[word_count_raw$word == "governance"] <- "government"
  145. word_count_raw$word[word_count_raw$word == "governmental"] <- "government"
  146. word_count_raw$word[word_count_raw$word == "governments"] <- "government"
  147. word_count_raw$word[word_count_raw$word == "governing"] <- "government"
  148. word_count_raw$word[word_count_raw$word == "groups"] <- "group"
  149. word_count_raw$word[word_count_raw$word == "heads"] <- "head"
  150. word_count_raw$word[word_count_raw$word == "helps"] <- "help"
  151. word_count_raw$word[word_count_raw$word == "helped"] <- "help"
  152. word_count_raw$word[word_count_raw$word == "helping"] <- "help"
  153. word_count_raw$word[word_count_raw$word == "helpers"] <- "help"
  154. word_count_raw$word[word_count_raw$word == "improved"] <- "improving"
  155. word_count_raw$word[word_count_raw$word == "inclusive"] <- "include"
  156. word_count_raw$word[word_count_raw$word == "includes"] <- "include"
  157. word_count_raw$word[word_count_raw$word == "including"] <- "include"
  158. word_count_raw$word[word_count_raw$word == "industries"] <- "industry"
  159. word_count_raw$word[word_count_raw$word == "industrial"] <- "industry"
  160. word_count_raw$word[word_count_raw$word == "influences"] <- "influence"
  161. word_count_raw$word[word_count_raw$word == "influential"] <- "influence"
  162. word_count_raw$word[word_count_raw$word == "institutes"] <- "institute"
  163. word_count_raw$word[word_count_raw$word == "internationally"] <- "international"
  164. word_count_raw$word[word_count_raw$word == "invented"] <- "invent"
  165. word_count_raw$word[word_count_raw$word == "invention"] <- "invent"
  166. word_count_raw$word[word_count_raw$word == "inventions"] <- "invent"
  167. word_count_raw$word[word_count_raw$word == "involved"] <- "involvement"
  168. word_count_raw$word[word_count_raw$word == "improve"] <- "improving"
  169. word_count_raw$word[word_count_raw$word == "iranian"] <- "iran"
  170. word_count_raw$word[word_count_raw$word == "irish"] <- "ireland"
  171. word_count_raw$word[word_count_raw$word == "journalist"] <- "journalism"
  172. word_count_raw$word[word_count_raw$word == "job"] <- "jobs"
  173. word_count_raw$word[word_count_raw$word == "known"] <- "know"
  174. word_count_raw$word[word_count_raw$word == "kyrgyz"] <- "kyrgyzstan"
  175. word_count_raw$word[word_count_raw$word == "lead"] <- "leader"
  176. word_count_raw$word[word_count_raw$word == "leads"] <- "leader"
  177. word_count_raw$word[word_count_raw$word == "leaders"] <- "leader"
  178. word_count_raw$word[word_count_raw$word == "leadership"] <- "leader"
  179. word_count_raw$word[word_count_raw$word == "life’s"] <- "life"
  180. word_count_raw$word[word_count_raw$word == "lives"] <- "life"
  181. word_count_raw$word[word_count_raw$word == "lines"] <- "line"
  182. word_count_raw$word[word_count_raw$word == "locally"] <- "local"
  183. word_count_raw$word[word_count_raw$word == "looks"] <- "look"
  184. word_count_raw$word[word_count_raw$word == "looking"] <- "look"
  185. word_count_raw$word[word_count_raw$word == "lyrical"] <- "lyrics"
  186. word_count_raw$word[word_count_raw$word == "maker"] <- "make"
  187. word_count_raw$word[word_count_raw$word == "making"] <- "make"
  188. word_count_raw$word[word_count_raw$word == "makers"] <- "make"
  189. word_count_raw$word[word_count_raw$word == "manages"] <- "manage"
  190. word_count_raw$word[word_count_raw$word == "manager"] <- "manage"
  191. word_count_raw$word[word_count_raw$word == "medical"] <- "medicine"
  192. word_count_raw$word[word_count_raw$word == "ministry"] <- "minister"
  193. word_count_raw$word[word_count_raw$word == "models"] <- "model"
  194. word_count_raw$word[word_count_raw$word == "movements"] <- "movement"
  195. word_count_raw$word[word_count_raw$word == "musician"] <- "music"
  196. word_count_raw$word[word_count_raw$word == "named"] <- "name"
  197. word_count_raw$word[word_count_raw$word == "nation"] <- "national"
  198. word_count_raw$word[word_count_raw$word == "networks"] <- "network"
  199. word_count_raw$word[word_count_raw$word == "nigerian"] <- "nigeria"
  200. word_count_raw$word[word_count_raw$word == "organisations"] <- "organisation"
  201. word_count_raw$word[word_count_raw$word == "outbreaks"] <- "outbreak"
  202. word_count_raw$word[word_count_raw$word == "pakistanis"] <- "pakistan"
  203. word_count_raw$word[word_count_raw$word == "parliamentary"] <- "parliament"
  204. word_count_raw$word[word_count_raw$word == "parties"] <- "party"
  205. word_count_raw$word[word_count_raw$word == "peacebuilders"] <- "peace"
  206. word_count_raw$word[word_count_raw$word == "peacefully"] <- "peace"
  207. word_count_raw$word[word_count_raw$word == "people’s"] <- "people"
  208. word_count_raw$word[word_count_raw$word == "performs"] <- "performing"
  209. word_count_raw$word[word_count_raw$word == "petitioners"] <- "petition"
  210. word_count_raw$word[word_count_raw$word == "pioneered"] <- "pioneer"
  211. word_count_raw$word[word_count_raw$word == "presidential"] <- "president"
  212. word_count_raw$word[word_count_raw$word == "preventive"] <- "prevention"
  213. word_count_raw$word[word_count_raw$word == "prevent"] <- "prevention"
  214. word_count_raw$word[word_count_raw$word == "prisoners"] <- "prison"
  215. word_count_raw$word[word_count_raw$word == "promote"] <- "promoting"
  216. word_count_raw$word[word_count_raw$word == "protect"] <- "protection"
  217. word_count_raw$word[word_count_raw$word == "protested"] <- "protest"
  218. word_count_raw$word[word_count_raw$word == "protester"] <- "protest"
  219. word_count_raw$word[word_count_raw$word == "protests"] <- "protest"
  220. word_count_raw$word[word_count_raw$word == "recorded"] <- "record"
  221. word_count_raw$word[word_count_raw$word == "reported"] <- "reporting"
  222. word_count_raw$word[word_count_raw$word == "reports"] <- "reporting"
  223. word_count_raw$word[word_count_raw$word == "researchers"] <- "research"
  224. word_count_raw$word[word_count_raw$word == "researches"] <- "research"
  225. word_count_raw$word[word_count_raw$word == "result"] <- "results"
  226. word_count_raw$word[word_count_raw$word == "right"] <- "rights"
  227. word_count_raw$word[word_count_raw$word == "russia's"] <- "russia"
  228. word_count_raw$word[word_count_raw$word == "russian"] <- "russia"
  229. word_count_raw$word[word_count_raw$word == "schoolchildren"] <- "children"
  230. word_count_raw$word[word_count_raw$word == "sciences"] <- "science"
  231. word_count_raw$word[word_count_raw$word == "scientist"] <- "science"
  232. word_count_raw$word[word_count_raw$word == "scientists"] <- "science"
  233. word_count_raw$word[word_count_raw$word == "scientists"] <- "science"
  234. word_count_raw$word[word_count_raw$word == "scots"] <- "scotland"
  235. word_count_raw$word[word_count_raw$word == "scottish"] <- "scotland"
  236. word_count_raw$word[word_count_raw$word == "screened"] <- "screen"
  237. word_count_raw$word[word_count_raw$word == "scientists"] <- "science"
  238. word_count_raw$word[word_count_raw$word == "sexual"] <- "sex"
  239. word_count_raw$word[word_count_raw$word == "showed"] <- "show"
  240. word_count_raw$word[word_count_raw$word == "singer"] <- "singing"
  241. word_count_raw$word[word_count_raw$word == "stories"] <- "story"
  242. word_count_raw$word[word_count_raw$word == "storyteller"] <- "story"
  243. word_count_raw$word[word_count_raw$word == "students"] <- "student"
  244. word_count_raw$word[word_count_raw$word == "studying"] <- "study"
  245. word_count_raw$word[word_count_raw$word == "supported"] <- "support"
  246. word_count_raw$word[word_count_raw$word == "supporting"] <- "support"
  247. word_count_raw$word[word_count_raw$word == "supports"] <- "support"
  248. word_count_raw$word[word_count_raw$word == "syrian"] <- "syria"
  249. word_count_raw$word[word_count_raw$word == "systems"] <- "system"
  250. word_count_raw$word[word_count_raw$word == "tackling"] <- "tackle"
  251. word_count_raw$word[word_count_raw$word == "talks"] <- "talk"
  252. word_count_raw$word[word_count_raw$word == "tech"] <- "technology"
  253. word_count_raw$word[word_count_raw$word == "technologies"] <- "technology"
  254. word_count_raw$word[word_count_raw$word == "tools"] <- "tool"
  255. word_count_raw$word[word_count_raw$word == "transformative"] <- "transform"
  256. word_count_raw$word[word_count_raw$word == "transforming"] <- "transform"
  257. word_count_raw$word[word_count_raw$word == "translated"] <- "translate"
  258. word_count_raw$word[word_count_raw$word == "translator"] <- "translate"
  259. word_count_raw$word[word_count_raw$word == "travelled"] <- "travel"
  260. word_count_raw$word[word_count_raw$word == "travellers"] <- "travel"
  261. word_count_raw$word[word_count_raw$word == "treated"] <- "treat"
  262. word_count_raw$word[word_count_raw$word == "turkish"] <- "turkey"
  263. word_count_raw$word[word_count_raw$word == "uk's"] <- "UK"
  264. word_count_raw$word[word_count_raw$word == "uk’s"] <- "UK"
  265. word_count_raw$word[word_count_raw$word == "uk"] <- "UK"
  266. word_count_raw$word[word_count_raw$word == "un"] <- "UN"
  267. word_count_raw$word[word_count_raw$word == "visualisation"] <- "visual"
  268. word_count_raw$word[word_count_raw$word == "vulnerability"] <- "vulnerable"
  269. word_count_raw$word[word_count_raw$word == "weeks"] <- "week"
  270. word_count_raw$word[word_count_raw$word == "winner"] <- "winning"
  271. word_count_raw$word[word_count_raw$word == "woman’s"] <- "women"
  272. word_count_raw$word[word_count_raw$word == "woman"] <- "winning"
  273. word_count_raw$word[word_count_raw$word == "women's"] <- "winning"
  274. word_count_raw$word[word_count_raw$word == "women’s"] <- "winning"
  275. word_count_raw$word[word_count_raw$word == "working"] <- "work"
  276. word_count_raw$word[word_count_raw$word == "worker"] <- "work"
  277. word_count_raw$word[word_count_raw$word == "workers"] <- "work"
  278. word_count_raw$word[word_count_raw$word == "worked"] <- "work"
  279. word_count_raw$word[word_count_raw$word == "works"] <- "work"
  280. word_count_raw$word[word_count_raw$word == "writing"] <- "writer"
  281. word_count_raw$word[word_count_raw$word == "written"] <- "writer"
  282. word_count_raw$word[word_count_raw$word == "years"] <- "year"
  283. word_count_raw$word[word_count_raw$word == "young"] <- "youth"
  284. word_count_raw$word[word_count_raw$word == "zambian"] <- "zambia"
  285.  
  286. ### Generate word counts from cleaned data:
  287. word_count_clean <-
  288.   word_count_raw %>%
  289.   filter(!is.na(word)) %>%
  290.   group_by(category, word) %>%
  291.   summarise(n = sum(n))
  292.  
  293. # Visualize
  294. # Suggested parameters for R notebook: fig.height=9, fig.width=8
  295. ## Create a plot for each category:
  296.  
  297. ### Creativity
  298. set.seed(42)
  299. creativity <-
  300.   word_count_clean %>%
  301.   slice_max(n, n = 25) %>%
  302.   filter(category == "Creativity") %>%
  303.   slice_head(n = 25) %>%
  304.   left_join(colors_df, by = "category") %>%
  305.   ggplot(aes(label = word, size = n, color = I(color))) +
  306.   geom_text_wordcloud(shape = "square", eccentricity = 1) +
  307.   scale_size_area(max_size = 12) +
  308.   facet_wrap(~category) +
  309.   theme(panel.border = element_blank(),
  310.         strip.background = element_rect(fill = "white", color = NA),
  311.         strip.text = element_text(size = 22, color = colors["Creativity"], face = "bold.italic"))
  312.  
  313. ### Identity
  314. set.seed(42)
  315. identity <-
  316.   word_count_clean %>%
  317.   slice_max(n, n = 25) %>%
  318.   filter(category == "Identity") %>%
  319.   slice_head(n = 25) %>%
  320.   left_join(colors_df, by = "category") %>%
  321.   ggplot(aes(label = word, size = n, color = I(color))) +
  322.   geom_text_wordcloud(shape = "square", eccentricity = 1) +
  323.   scale_size_area(max_size = 12) +
  324.   facet_wrap(~category) +
  325.   theme(panel.border = element_blank(),
  326.         strip.background = element_rect(fill = "white", color = NA),
  327.         strip.text = element_text(size = 22, color = colors["Identity"], face = "bold.italic"))
  328.  
  329. ### Knowledge
  330. set.seed(42)
  331. knowledge <-
  332.   word_count_clean %>%
  333.   slice_max(n, n = 25) %>%
  334.   filter(category == "Knowledge") %>%
  335.   slice_head(n = 25) %>%
  336.   left_join(colors_df, by = "category") %>%
  337.   ggplot(aes(label = word, size = n, color = I(color))) +
  338.   geom_text_wordcloud(shape = "square", eccentricity = 1) +
  339.   scale_size_area(max_size = 10) +
  340.   facet_wrap(~category) +
  341.   theme(panel.border = element_blank(),
  342.         strip.background = element_rect(fill = "white", color = NA),
  343.         strip.text = element_text(size = 22, color = colors["Knowledge"], face = "bold.italic"))
  344.  
  345. ### Leadership
  346. set.seed(42)
  347. leadership <-
  348.   word_count_clean %>%
  349.   slice_max(n, n = 25) %>%
  350.   filter(category == "Leadership") %>%
  351.   slice_head(n = 25) %>%
  352.   left_join(colors_df, by = "category") %>%
  353.   ggplot(aes(label = word, size = n, color = I(color))) +
  354.   geom_text_wordcloud(shape = "square", eccentricity = 1) +
  355.   scale_size_area(max_size = 10) +
  356.   facet_wrap(~category) +
  357.   theme(panel.border = element_blank(),
  358.         strip.background = element_rect(fill = "white", color = NA),
  359.         strip.text = element_text(size = 22, color = colors["Leadership"], face = "bold.italic"))
  360.  
  361. ### Overall theme for patchwork:
  362. plot_theme <- theme(plot.title = element_text(colour = dark_grey),
  363.                     plot.subtitle = element_text(color = dark_grey),
  364.                     plot.caption = element_text(color = dark_grey))
  365.  
  366. ### Use patchwork to piece together the four plots:
  367. plot1 <- (creativity + identity) / (knowledge + leadership) +
  368.   plot_annotation(title = expression(paste(bold("Women of 2020"), " - Word clouds of The BBC's 100 Women of 2020.")),
  369.                   subtitle = str_wrap("The word clouds are grouped by category and are generated from the text description for each Woman of 2020."),
  370.                   caption = expression(paste("Created by: ", italic("reddit.com/user/brianhaas19"), "  Data source: ", italic("https://github.com/rfordatascience/tidytuesday/blob/master/data/2020/2020-12-08"))),
  371.                   theme = plot_theme)
  372.  
  373. ### File path of logo:
  374. logo_file <- str_c(getwd(), "/img/logo.png")
  375.  
  376. ### Add the logo to the plot:
  377. plot2 <- ggdraw(plot1) +
  378.   draw_image(logo_file, x = 1.15, y = 1,
  379.              hjust = 1, vjust = 1,
  380.              width = 0.4, height = 0.08)
  381.  
  382. ### View/save the plot:
  383. #png(filename = str_c(getwd(), "/women_of_2020.png"), width = 8, height = 9, units = "in", res = 200) # uncomment to save to disk
  384. plot2
  385. #dev.off() # uncomment to save to disk
  386. ###################################################################################################
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×