library(tidyverse)
## -- Attaching packages ---------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.2.1     v purrr   0.3.3
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   1.0.0     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.4.0
## -- Conflicts ------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

I chose to work with the Avengers dataset

# Get dataset from URL from FiveThirtyEight github
Avengers <- read.csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/avengers/avengers.csv")

I chose to demonstrate the dplyr package

# Use filter to extract an individual avenger
Captain_America <- filter(Avengers, Name.Alias == "Steven Rogers")
Iron_Man <- filter(Avengers, Appearances == "3068")
Thor <- filter(Avengers, Name.Alias == "Thor Odinson")
Black_Widow <- filter(Avengers, Name.Alias == "Natalia Alianovna Romanova")
The_Hulk <- filter(Avengers, Name.Alias == "Robert Bruce Banner")
Hawkeye <- filter(Avengers, Name.Alias == "Clinton Francis Barton")
# Use full_join to combine everything into one data frame
Avengers_2012 <- list(Captain_America, Iron_Man, Thor, Black_Widow, The_Hulk, Hawkeye) %>%
  reduce(full_join, by.x = "URL", by.y = "Appearances")
## Joining, by = c("URL", "Name.Alias", "Appearances", "Current.", "Gender", "Probationary.Introl", "Full.Reserve.Avengers.Intro", "Year", "Years.since.joining", "Honorary", "Death1", "Return1", "Death2", "Return2", "Death3", "Return3", "Death4", "Return4", "Death5", "Return5", "Notes")
## Joining, by = c("URL", "Name.Alias", "Appearances", "Current.", "Gender", "Probationary.Introl", "Full.Reserve.Avengers.Intro", "Year", "Years.since.joining", "Honorary", "Death1", "Return1", "Death2", "Return2", "Death3", "Return3", "Death4", "Return4", "Death5", "Return5", "Notes")
## Joining, by = c("URL", "Name.Alias", "Appearances", "Current.", "Gender", "Probationary.Introl", "Full.Reserve.Avengers.Intro", "Year", "Years.since.joining", "Honorary", "Death1", "Return1", "Death2", "Return2", "Death3", "Return3", "Death4", "Return4", "Death5", "Return5", "Notes")
## Joining, by = c("URL", "Name.Alias", "Appearances", "Current.", "Gender", "Probationary.Introl", "Full.Reserve.Avengers.Intro", "Year", "Years.since.joining", "Honorary", "Death1", "Return1", "Death2", "Return2", "Death3", "Return3", "Death4", "Return4", "Death5", "Return5", "Notes")
## Joining, by = c("URL", "Name.Alias", "Appearances", "Current.", "Gender", "Probationary.Introl", "Full.Reserve.Avengers.Intro", "Year", "Years.since.joining", "Honorary", "Death1", "Return1", "Death2", "Return2", "Death3", "Return3", "Death4", "Return4", "Death5", "Return5", "Notes")
Avengers_2012
##                                                       URL
## 1       http://marvel.wikia.com/Steven_Rogers_(Earth-616)
## 2       http://marvel.wikia.com/Anthony_Stark_(Earth-616)
## 3        http://marvel.wikia.com/Thor_Odinson_(Earth-616)
## 4   http://marvel.wikia.com/Natalia_Romanova_(Earth-616)#
## 5 http://marvel.wikia.com/Robert_Bruce_Banner_(Earth-616)
## 6        http://marvel.wikia.com/Clint_Barton_(Earth-616)
##                    Name.Alias Appearances Current. Gender
## 1               Steven Rogers        3458      YES   MALE
## 2 Anthony Edward "Tony" Stark        3068      YES   MALE
## 3                Thor Odinson        2402      YES   MALE
## 4  Natalia Alianovna Romanova        1112      YES FEMALE
## 5         Robert Bruce Banner        2089      YES   MALE
## 6      Clinton Francis Barton        1456      YES   MALE
##   Probationary.Introl Full.Reserve.Avengers.Intro Year Years.since.joining
## 1                                          Mar-64 1964                  51
## 2                                          Sep-63 1963                  52
## 3                                          Sep-63 1963                  52
## 4                                          May-73 1973                  42
## 5                                          Sep-63 1963                  52
## 6                                          May-65 1965                  50
##   Honorary Death1 Return1 Death2 Return2 Death3 Return3 Death4 Return4
## 1     Full    YES     YES                                             
## 2     Full    YES     YES                                             
## 3     Full    YES     YES    YES      NO                              
## 4     Full    YES     YES                                             
## 5     Full    YES     YES                                             
## 6     Full    YES     YES    YES     YES                              
##   Death5 Return5
## 1               
## 2               
## 3               
## 4               
## 5               
## 6               
##                                                                                                                                                                              Notes
## 1                                                                                                                                 Dies at the end of Civil War. Later comes back. 
## 2 Death: "Later while under the influence of Immortus Stark committed a number of horrible acts and was killed.'  This set up young Tony. Franklin Richards later brought him back
## 3                                                      Dies in Fear Itself brought back because that's kind of the whole point. Second death in Time Runs Out has not yet returned
## 4                                                                                                                 Killed by The Hand. Later revived with The Stone of the Chaste. 
## 5                                                                               Dies in Ghosts of the Future arc. However "he had actually used a hidden Pantheon base to survive"
## 6                       Dies in exploding Kree ship in Averngers Vol. 1  Issue 502. Brought back by Scarlet Witch. Dies again in House of M Vol 1 Issue 7. Is later brought back.

For my Tidyverse example I used the Avengers dataset from FiveThirtyEight. The dataset contains a list of members of the Avengers group from the Marvel comics. The list shows appearances of when they were first introduced in the comics and if/when they died and/or returned. I used the filter function from the dplyr package to extract every avenger from the 2012 Avengers film. I then put them into a list and used the full_join function from the dplyr function to put every avenger that I got from using the filter function into one data frame.

Some Visualizations: Edited by Farhana Zahir

No of appearances by the Avengers

ggplot(Avengers_2012, aes(x=Name.Alias, y=as.numeric(Appearances)))+
  geom_bar(stat='identity')+
  ggtitle("Number of appearances by selected Avengers")+
  theme(axis.text.x = element_text(angle = 90))

Male vs Female Avengers Percentage

gender<-Avengers%>%
  select(Gender, Appearances)%>%
  group_by(Gender)%>%
  summarise(total=sum(Appearances))%>%
  mutate(Percentage=total/sum(total))
gender
## # A tibble: 2 x 3
##   Gender total Percentage
##   <fct>  <int>      <dbl>
## 1 FEMALE 15273      0.213
## 2 MALE   56358      0.787