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

Data description

This data set is about characters in the Star Wars movie saga. The data comes from SWAPI, which is an API containing all Star Wars characters from Episodes I-VII. It is unclear as how much the data has been processed, but appears to be current as Episode IV came out within the last 5 years.

Link to SAWPI “About” page for further reading if so desired

Summary table:

Variable Description
name Name of character
height Height of character in centimeters
mass Mass of character in kilograms
hair_color Hair color of character
skin_color Skin color of character
eye_color Eye color of character
birth_year Birth year of character
gender Gender of character
homeworld Home-planet of character
species Type of species character is
films Name of films character appears in
vehicles Name of vehicles used by character
starships Name of starships used by character

Data visualizations

# Write R code here to load your data file
library(dplyr)
starwars
## # A tibble: 87 x 13
##    name  height  mass hair_color skin_color eye_color birth_year gender
##    <chr>  <int> <dbl> <chr>      <chr>      <chr>          <dbl> <chr> 
##  1 Luke…    172    77 blond      fair       blue            19   male  
##  2 C-3PO    167    75 <NA>       gold       yellow         112   <NA>  
##  3 R2-D2     96    32 <NA>       white, bl… red             33   <NA>  
##  4 Dart…    202   136 none       white      yellow          41.9 male  
##  5 Leia…    150    49 brown      light      brown           19   female
##  6 Owen…    178   120 brown, gr… light      blue            52   male  
##  7 Beru…    165    75 brown      light      blue            47   female
##  8 R5-D4     97    32 <NA>       white, red red             NA   <NA>  
##  9 Bigg…    183    84 black      light      brown           24   male  
## 10 Obi-…    182    77 auburn, w… fair       blue-gray       57   male  
## # … with 77 more rows, and 5 more variables: homeworld <chr>, species <chr>,
## #   films <list>, vehicles <list>, starships <list>
starwars %>%
  mutate(heightinm = height/100)%>%
  mutate(heightinmsquared = heightinm^2)%>%
  mutate(bmi = mass/heightinmsquared)%>%
  filter(mass < 500)%>%
  ggplot()+
  geom_point(aes(x=mass, y=bmi))+
  labs(
    x="Mass",
    y="Body Mass Index (kg/m^2)",
    title="Body Mass Index of Star Wars Characters vs Mass"
  )

This scatterplot shows the body mass index of characters in Star Wars plotted against their mass. Body mass index was calculated by taking the mass in kilograms then dividing by the square of the height in meters. The measure of body mass index comes with the critical vaues of less than 18.5 being “underweight”, 18.5-25 being “normal”, 25-30 being “overweight”, and 30 and above being considered “obese”. In order to better visualize the data, characters (1) with a mass greater than 500 were excluded from this scatterplot. From this scatterplot we can interpolate that characters with higher masses are more likley to be obese. The majority of characters lie in the range of normal to slightly overweight (<27 bmi). It can also be interpreted that characters with less mass are more likley to be underweight.

Link to where information about Body Mass Index was gathered from

starwars %>%
  mutate(heightinm = height/100)%>%
  mutate(heightinmsquared = heightinm^2)%>%
  mutate(bmi = mass/heightinmsquared)%>%
  filter(mass < 500)%>%
  filter(species=="Human")%>%
  ggplot()+
  geom_point(aes(x=mass, y=bmi))+
  labs(
    x="Mass",
    y="Body Mass Index (kg/m^2)",
    title="Body Mass Index of Human Star Wars Characters"
  )

This scatterplot is the same as above except that only human characters were plotted. Using the same critical values of less than 18.5 being “underweight”, 18.5-25 being “normal”, 25-30 being “overweight”, and 30 and above being considered “obese”, we can conclude that nearly half of the human characters in Star Wars would be conisdered “overweight” or “obese”. Approximentally half would be considered to be in the “normal” BMI range, with only one character being considered underweight. Three characters would be considered obese, and they all have higher masses. Therefore we can infer that our same conclusions from the prior graph apply. However, opposed to the previous graph there seems to be no corelation between lower mass people and being “underweight”, but this could be due to the number of characters sampled in the plot.

Link to where information about Body Mass Index was gathered from

starwars%>%
  filter(!is.na(gender))%>%
  group_by(gender)%>%
  ggplot()+
  geom_bar(aes(x=gender))+
  labs(
    x="Gender",
    y="Characters",
    title="Number of Characters"
    )

This histogram shows the number of characters spread accross the 4 reported genders in the data set. These variables were chosen to show the relationship between gender and number of characters in the Star Wars Saga. This graph shows that the number of males is more than double the amount of females. It could be possible that this is because Star Wars was likley orginally targeted toward male audiences.