The starwars Dataset in R


The starwars dataset is a built-in dataset in the dplyr package. Check out the tidyverse website for more information about dplyr.

colnames

> colnames(starwars)
 [1] "name"       "height"     "mass"       "hair_color" "skin_color" "eye_color"  "birth_year"
 [8] "sex"        "gender"     "homeworld"  "species"    "films"      "vehicles"   "starships" 

glimpse

> glimpse(starwars)
Rows: 87
Columns: 14
$ name       <chr> "Luke Skywalker", "C-3PO", "R2-D2", "Darth Vader", "Leia Organa"…
$ height     <int> 172, 167, 96, 202, 150, 178, 165, 97, 183, 182, 188, 180, 228, 1…
$ mass       <dbl> 77.0, 75.0, 32.0, 136.0, 49.0, 120.0, 75.0, 32.0, 84.0, 77.0, 84…
$ hair_color <chr> "blond", NA, NA, "none", "brown", "brown, grey", "brown", NA, "b…
$ skin_color <chr> "fair", "gold", "white, blue", "white", "light", "light", "light…
$ eye_color  <chr> "blue", "yellow", "red", "yellow", "brown", "blue", "blue", "red…
$ birth_year <dbl> 19.0, 112.0, 33.0, 41.9, 19.0, 52.0, 47.0, NA, 24.0, 57.0, 41.9,…
$ sex        <chr> "male", "none", "none", "male", "female", "male", "female", "non…
$ gender     <chr> "masculine", "masculine", "masculine", "masculine", "feminine", …
$ homeworld  <chr> "Tatooine", "Tatooine", "Naboo", "Tatooine", "Alderaan", "Tatooi…
$ species    <chr> "Human", "Droid", "Droid", "Human", "Human", "Human", "Human", "…
$ films      <list> <"The Empire Strikes Back", "Revenge of the Sith", "Return of t…
$ vehicles   <list> <"Snowspeeder", "Imperial Speeder Bike">, <>, <>, <>, "Imperial…
$ starships  <list> <"X-wing", "Imperial shuttle">, <>, <>, "TIE Advanced x1", <>, …

To learn more about dplyr, you could go to the online version of the book R for Data Science, Chapter 5 Data Transformation.

Leave a Reply