R/Data Science Project.R

#Purpose of Project: Currently, Disney is praised for highlighting female superhero narratives on screen, 
#I wanted to to see if  Marvel comic books writers devoted themselves to the same mission since it's inception in the 1960's.#
#Code from Katelynn Barkley's Avengers Project#
#Load all library packages that will be used#
library(dplyr)

library(ggplot2)

library(tidyr)

library(tidyverse)

library(cluster.datasets)

#Set working directory of file from my downloads#
setwd("~/Downloads/data-master/avengers")

#Read CSV File#
av<- read.csv("Avengers.csv")

#Look at Overall Structure of Imported Data#
str(avengers)

#Obtain a Closer Glimpose of Imported Data#
glimpse(avengers)

#Observe the Class of Columns of Interest#
class("Death1")
class("Years.since.joining")
class("Appearances")

#Create scatterplot of Y=Appearances vs. X=Years Since Joining#
#First, name the ggplot as p#

p<- ggplot(data=av, aes(x=Years.since.joining, y=Appearances, color=Gender)) +geom_point(shape = 5, size = 2) + xlab("Number of Years Since Joined") + ylab("Appearances") + ggtitle("Does Avenger's Gender Affect their Number of Appearances?") + theme_classic()

#Finish ggplot creation with scales, colors :

p + coord_cartesian(xlim = seq(0,150,25), ylim = c(0, 4000))
p + scale_color_manual(values=c("#999999", "#E69F00"))

#Comments:
#Purpose of this graph is to answer the question: Is there an equal distribution of males and females when it comes to the number of years since joined vs. number of appearances.#
#As time progresses, it is seen that the amount of Avengers appearing past 60 years in the commic is rare. However, there is a denser distribution of males at about 120 years compared to the female distribution at that time.#
#As the oppurtunity for appearance increases on the y, it is seen that the amount of female appearances hault at around 1,800 appearances. Whereas, the amount of male appearances increases as the oppurtunity for appearances/exposure increases.#
#There is a concentration of male appearances between 0 to 1,000 appearances, which overshadows the amount of female appearance present.#
#In this case, it is rare for a female Avenger to appear beyond 60 years and a female's oppurtunity to appear in the comic between 1 to 1,000 times is overshadowed by the dense appearance of male Avengers during this time.#
#The original comic book seems provides less visisbility for females, especially at the beginning of their Avengers membership.#

#Create boxplot of Y=Years Since Joining vs X=Gender#

ggplot(data=av, aes(x=Gender,y = Years.since.joining, color = Gender)) +geom_boxplot()
#Purpose of this graph is to answer the question: Is there an equal distribution of males and females when it comes to the number of years since joining.#
#There seems to be an equal first quartile and third quartile between the female and male grouped boxplots.#
#So, the interquartile ranges are reasonably similar and both genders have equal dispersion as shown by the lengths of their boxes.#
#A difference to note here is that the median years since joining for females is greater than the median year since joinging for male Avengers.#

#Create boxplot of Y=Years Since Joining vs X=Gender according to a character's first death#
ggplot(data=av, aes(x=Gender,y = Years.since.joining, color = Death1)) +geom_boxplot()
#Purpose of this graph is to answer the question: Is there an equal distribution of males and females when it comes to the deaths experienced.#
#Here, it is apparent that female Avengers experience more first deaths than male Avengers because of the dispersion and location of the ranges.# 
#The dispersion female deaths has a smaller range than the dispersion of male deaths. The female deaths boxplot is comparatively short compared to female survival.#
#This suggests that female Avenegers have a concentrated amount of death between 25 to 40 years in the Avengers compared to male deaths which possess a more dispersed amount of deaths between 5 to 37 years.#
#So there seems to be an similarity in the maximum amount of time of membership before an a female or male Avenger dies because female Avengers have an expected shelf life between 25 to 40 years which is more concentrated in dispersion versus male shelf of 5 to 37 years.
#According to the first female death quartile, 25% of female Avengers deaths fall below 25 years of membership whereas 25% of male Avengers deaths fall below 5 years of membership.#
#In addition, 75% of the female Avengers deaths fall below 40 years of membership whereas 75% of male Avengers deaths fall bellow 35 years of membership.#
#Half of the female deaths occurred at almost 30 years of membership whereas half of the male deaths occurred at a lttle over 20 years of membership.#
#With female deaths containing a slightly higher third quartile and noticeably higher median compared to female survivals, female death occurred more than female survival.
#With female deaths containing a slightly higher third quartile and slightly higher median compared to male death, female death occurred slightly more than male deaths.

#Create boxplot of Y=Years Since Joining vs X=Gender according to a character's first death#
ggplot(data=av, aes(x=Gender,y = Years.since.joining, color = Return1)) +geom_boxplot()
#Purpose of this graph is to answer the question: Is there an equal distribution of males and females when it comes to the chance of a character's return.#
#Although there is a similarity in the maximum amount of time of membership before an a female or male Avenger dies, there is a difference in amount of females vs. males returning from the dead.#
#The dispersion female returns has a smaller range and lower median than the dispersion of male returns. The female returns boxplot is comparatively short compared to male returns.#
#In addition, the female returns have no outliers, a higher third quartile. Whereas, male returns has an outlier, a much greater third quartile.
#75% of female returns will occur at less than 40 years of membership an 75% of male returns will occur at less than 50 years of membership. This means that females are less likely to return after 40 years of membership and males are less likely to return after 50 years of membership. 
#This means that male Avengers live on within the comics for 10 more years after their return from their first death compared to the females.
#Therefore, females were less likely to return after their first death compared to men. It is important to note that although females and males have almost equal amount of death in membership before their first death, we're less likely to see females after their first death compared to the increased likelihood of seeing male Avengers after their first death.#
#This lessens the likelihood of seeing a female Avenger character after 30 years of membership (around the time of their first death) compared to male Avengers. There is less visibility of females in this respect.#

#Conclusion:
#There was less difference in the dispersion of the amount of years of membership it took before an Avenger died for females and males. So in this respects, Marvel comics were fair in allocating the number of years a female vs male was in their Avengers membership before he/she passed.
#However, there is less female visibility when their chance of returning is noticeably smaller than a male Avenger's chance of returning.
#This is where the male Avengers obtain their visibility which is through the return of a male character, whereas a female Avenger is not afforded that oppurtunity. This is where Marvel comics fall short in female visibility.
katelynn-barkley/FemRepinAvengers1 documentation built on Dec. 23, 2019, 10:21 p.m.