-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
95 lines (71 loc) · 2.48 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: "Data and Donuts: African American Accomplishments Data"
author: "BioData Club Members"
date: "`r Sys.Date()`"
output:
html_document:
df_print: paged
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(plotly)
library(skimr)
```
## More Info About this Dataset
https://github.com/rfordatascience/tidytuesday/tree/master/data/2020/2020-06-09
## The Tables
There are two different tables that we'll be looking at in the `data` folder.
```{r}
firsts <- read_csv("data/firsts.csv") %>%
mutate(row_num = row_number()) %>%
select(row_num, year, category, gender, person, accomplishment)
science <- read_csv("data/science.csv")
```
# Nicola Long
```{r}
knitr::include_graphics("image/FirstsGraph.png")
```
# Pierrette Lo
```{r}
knitr::include_graphics("image/aaa_bump_plot.png")
```
# Ted Laderas
```{r fig.width=8, fig.height=8}
library(plotly)
library(wesanderson)
new_firsts_wrapped <- firsts %>%
mutate(row_num = fct_reorder(as.factor(row_num), year)) %>%
mutate(accomplishment = str_wrap(accomplishment, width = 40)) %>%
mutate(category = fct_rev(category)) %>%
filter(category %in% c("Arts & Entertainment", "Education & Science", "Politics", "Social & Jobs", "Sports"))
new_plot <- ggplot(new_firsts_wrapped) +
aes(x=year, y=category, person = person,
label=accomplishment, color=category) +
geom_jitter() +
theme(legend.position = "none", axis.title.y = element_blank()) +
labs(title = "African American Firsts") +
scale_color_manual(values = wes_palette("Darjeeling1", n = 5))
label_format <- list(align="left")
ggplotly(new_plot,tooltip = c( "person", "year", "accomplishment", "category")) %>%
style(hoverlabel = label_format)
```
```{r fig.width=8, fig.height=8}
library(plotly)
science_subset <- science %>%
filter(grepl('nvent', occupation_s, fixed=FALSE)) %>%
mutate(name = fct_reorder(name, birth)) %>%
mutate(death = tidyr::replace_na(death, 2020)) %>%
mutate(inventions_accomplishments = str_wrap(inventions_accomplishments, width = 50))
sci_plot <- ggplot(science_subset) +
aes(x=birth, xend=death, y=name, yend = name,
name = name, label=inventions_accomplishments, color=occupation_s) +
geom_point() +
geom_point(aes(x=death)) +
geom_segment() +
theme(legend.position = "none") +
labs(title = "African American Inventors")
lab <- list(align="left")
ggplotly(sci_plot,tooltip = c("name", "occupation_s", "inventions_accomplishments")) %>%
style(hoverlabel = lab)
```