glimpse(starwars)
## Rows: 87
## Columns: 14
## $ name <chr> "Luke Skywalker", "C-3PO", "R2-D2", "Darth Vader", "Leia Or…
## $ height <int> 172, 167, 96, 202, 150, 178, 165, 97, 183, 182, 188, 180, 2…
## $ mass <dbl> 77.0, 75.0, 32.0, 136.0, 49.0, 120.0, 75.0, 32.0, 84.0, 77.…
## $ hair_color <chr> "blond", NA, NA, "none", "brown", "brown, grey", "brown", N…
## $ skin_color <chr> "fair", "gold", "white, blue", "white", "light", "light", "…
## $ eye_color <chr> "blue", "yellow", "red", "yellow", "brown", "blue", "blue",…
## $ birth_year <dbl> 19.0, 112.0, 33.0, 41.9, 19.0, 52.0, 47.0, NA, 24.0, 57.0, …
## $ sex <chr> "male", "none", "none", "male", "female", "male", "female",…
## $ gender <chr> "masculine", "masculine", "masculine", "masculine", "femini…
## $ homeworld <chr> "Tatooine", "Tatooine", "Naboo", "Tatooine", "Alderaan", "T…
## $ species <chr> "Human", "Droid", "Droid", "Human", "Human", "Human", "Huma…
## $ films <list> <"The Empire Strikes Back", "Revenge of the Sith", "Return…
## $ vehicles <list> <"Snowspeeder", "Imperial Speeder Bike">, <>, <>, <>, "Imp…
## $ starships <list> <"X-wing", "Imperial shuttle">, <>, <>, "TIE Advanced x1",…
"pink".ggplot(starwars,
aes(x = height, y = mass, color = gender, size = birth_year)) +
geom_point(color = "pink")
## Warning: Removed 51 rows containing missing values (geom_point).
ggplot(starwars,
aes(x = height, y = mass, color = gender, size = birth_year)) +
geom_point(color = "#30509C") +
labs(
title = "Star Wars Data",
x = "Height",
y = "Mass",
size = "Birth Year"
)
## Warning: Removed 51 rows containing missing values (geom_point).
(A little bit of starter code is provided below, and the code chunk
is set to not be evaluated with eval: false because the
current code in there is not valid code and hence the document wouldn’t
knit. Once you replace the code with valid code, set the chunk option to
eval: true, or remove the eval option
altogether since it’s set to true by default.)
ggplot(starwars, aes(x = mass)) +
geom_histogram(binwidth = 15)
## Warning: Removed 28 rows containing non-finite values (stat_bin).
ggplot(starwars, aes(x = sex)) +
geom_bar()
Interpretation goes here… The Star Wars Cast is majority male.
ggplot(starwars, aes(x = hair_color)) +
geom_bar()
ggplot(starwars, aes(x = sex,
fill = species)) +
geom_bar()
Interpretation goes here… Droids must go under “none” for their sex within this dataset.
(This time no starter code is provided, you’re on your own!)
ggplot(starwars, aes(x = mass, fill = sex)) +
geom_histogram(binwidth = 100) +
facet_wrap(~ sex, nrow = 3)
## Warning: Removed 28 rows containing non-finite values (stat_bin).
Interpretation goes here… The hermaphroditic character is an outlier in this data set because there is only one, and its mass is far different from how every other sex’s mass appears.