class: middle, inverse .leftcol30[ <center> <img src="https://github.com/emse-p4a-gwu/emse-p4a-gwu.github.io/raw/master/images/p4a_hex_sticker.png" width=250> </center> ] .rightcol70[ # Week 11: .fancy[Programming with Data] ###
EMSE 4571: Intro to Programming for Analytics ###
John Paul Helveston ###
April 13, 2023 ] --- class: inverse # Quiz 6
10
:
00
.leftcol[ ## Write your name on the quiz! ## Rules: - Work alone; no outside help of any kind is allowed. - No calculators, no notes, no books, no computers, no phones. ] .rightcol[ <br> <center> <img src="https://github.com/emse-p4a-gwu/2022-Spring/raw/main/images/quiz_doge.png" width="400"> </center> ] --- class: inverse, middle # Week 11: .fancy[Programming with Data] ### 1. Writing functions for data frames ### 2. Writing custom plot functions ### BREAK ### 3. Iteration with purrr --- class: inverse, middle # Week 11: .fancy[Programming with Data] ### 1. .orange[Writing functions for data frames] ### 2. Writing custom plot functions ### BREAK ### 3. Iteration with purrr --- # Motivation I want a summary of a variable in a data frame: ```r head(diamonds) ``` ``` #> # A tibble: 6 × 10 #> carat cut color clarity depth table price x y z #> <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl> #> 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 #> 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 #> 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 #> 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63 #> 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 #> 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 ``` --- # Motivation I want a summary of a variable in a data frame: ```r length(diamonds$price) ``` ``` #> [1] 53940 ``` ```r mean(diamonds$price) ``` ``` #> [1] 3932.8 ``` ```r sd(diamonds$price) ``` ``` #> [1] 3989.44 ``` --- # Motivation I want a summary of a variable in a data frame: ```r diamonds %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) ``` ``` #> # A tibble: 1 × 3 #> n mean sd #> <int> <dbl> <dbl> #> 1 53940 3933. 3989. ``` --- # Motivation I can get **grouped** summaries really fast now: .leftcol[ ```r diamonds %>% * group_by(cut) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) ``` ``` #> # A tibble: 5 × 4 #> cut n mean sd #> <ord> <int> <dbl> <dbl> #> 1 Fair 1610 4359. 3560. #> 2 Good 4906 3929. 3682. #> 3 Very Good 12082 3982. 3936. #> 4 Premium 13791 4584. 4349. #> 5 Ideal 21551 3458. 3808. ``` ] .rightcol[ ```r diamonds %>% * group_by(color) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) ``` ``` #> # A tibble: 7 × 4 #> color n mean sd #> <ord> <int> <dbl> <dbl> #> 1 D 6775 3170. 3357. #> 2 E 9797 3077. 3344. #> 3 F 9542 3725. 3785. #> 4 G 11292 3999. 4051. #> 5 H 8304 4487. 4216. #> 6 I 5422 5092. 4722. #> 7 J 2808 5324. 4438. ``` ] --- # Convert this to a function .leftcol[ ```r diamonds %>% group_by(color) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) ``` ``` #> # A tibble: 7 × 4 #> color n mean sd #> <ord> <int> <dbl> <dbl> #> 1 D 6775 3170. 3357. #> 2 E 9797 3077. 3344. #> 3 F 9542 3725. 3785. #> 4 G 11292 3999. 4051. #> 5 H 8304 4487. 4216. #> 6 I 5422 5092. 4722. #> 7 J 2808 5324. 4438. ``` ] .rightcol[ ```r my_summary <- function(df, var) { df %>% * group_by(var) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) } ``` ] --- # ...but this doesn't work ```r my_summary <- function(df, var) { df %>% * group_by(var) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) } my_summary(diamonds, color) ``` ``` #> Error in `group_by()`: #> ! Must group by variables found in `.data`. #> ✖ Column `var` is not found. ``` --- # **Solution**: "embrace" your variables 🤗 .leftcol[ ```r my_summary <- function(df, var) { df %>% * group_by({{ var }}) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) } ``` ] .rightcol[ ```r my_summary(diamonds, cut) ``` ``` #> # A tibble: 5 × 4 #> cut n mean sd #> <ord> <int> <dbl> <dbl> #> 1 Fair 1610 4359. 3560. #> 2 Good 4906 3929. 3682. #> 3 Very Good 12082 3982. 3936. #> 4 Premium 13791 4584. 4349. #> 5 Ideal 21551 3458. 3808. ``` ```r my_summary(diamonds, color) ``` ``` #> # A tibble: 7 × 4 #> color n mean sd #> <ord> <int> <dbl> <dbl> #> 1 D 6775 3170. 3357. #> 2 E 9797 3077. 3344. #> 3 F 9542 3725. 3785. #> 4 G 11292 3999. 4051. #> 5 H 8304 4487. 4216. #> 6 I 5422 5092. 4722. #> 7 J 2808 5324. 4438. ``` ] --- ### Make it even more general! ```r my_summary <- function(df, group, var) { df %>% group_by({{ group }}) %>% summarise( n = n(), mean = mean({{ var }}), sd = sd({{ var }}) ) } ``` ```r my_summary(diamonds, cut, price) ``` ``` #> # A tibble: 5 × 4 #> cut n mean sd #> <ord> <int> <dbl> <dbl> #> 1 Fair 1610 4359. 3560. #> 2 Good 4906 3929. 3682. #> 3 Very Good 12082 3982. 3936. #> 4 Premium 13791 4584. 4349. #> 5 Ideal 21551 3458. 3808. ``` --- ### Make it even more general! ```r my_summary <- function(df, group, var) { df %>% group_by({{ group }}) %>% summarise( n = n(), mean = mean({{ var }}), sd = sd({{ var }}) ) } ``` ```r my_summary(diamonds, color, carat) ``` ``` #> # A tibble: 7 × 4 #> color n mean sd #> <ord> <int> <dbl> <dbl> #> 1 D 6775 0.658 0.360 #> 2 E 9797 0.658 0.369 #> 3 F 9542 0.737 0.398 #> 4 G 11292 0.771 0.441 #> 5 H 8304 0.912 0.521 #> 6 I 5422 1.03 0.579 #> 7 J 2808 1.16 0.596 ``` --- ### Use it on a different data frame! .leftcol[ ```r library(palmerpenguins) glimpse(penguins) ``` ``` #> Rows: 344 #> Columns: 8 #> $ species <fct> Adelie, Adelie, Adelie, Adelie, Adelie, Adelie, Adel… #> $ island <fct> Torgersen, Torgersen, Torgersen, Torgersen, Torgerse… #> $ bill_length_mm <dbl> 39.1, 39.5, 40.3, NA, 36.7, 39.3, 38.9, 39.2, 34.1, … #> $ bill_depth_mm <dbl> 18.7, 17.4, 18.0, NA, 19.3, 20.6, 17.8, 19.6, 18.1, … #> $ flipper_length_mm <int> 181, 186, 195, NA, 193, 190, 181, 195, 193, 190, 186… #> $ body_mass_g <int> 3750, 3800, 3250, NA, 3450, 3650, 3625, 4675, 3475, … #> $ sex <fct> male, female, female, NA, female, male, female, male… #> $ year <int> 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007… ``` ] -- .rightcol[ ```r my_summary(penguins, sex, body_mass_g) ``` ``` #> # A tibble: 3 × 4 #> sex n mean sd #> <fct> <int> <dbl> <dbl> #> 1 female 165 3862. 666. #> 2 male 168 4546. 788. #> 3 <NA> 11 NA NA ``` ```r my_summary(penguins, species, bill_length_mm) ``` ``` #> # A tibble: 3 × 4 #> species n mean sd #> <fct> <int> <dbl> <dbl> #> 1 Adelie 152 NA NA #> 2 Chinstrap 68 48.8 3.34 #> 3 Gentoo 124 NA NA ``` ] --- ### Defining a filter condition ```r filter_summary <- function(df, condition, var) { df %>% * filter({{ condition }}) %>% summarise( n = n(), mean = mean({{ var }}, na.rm = TRUE), sd = sd({{ var }}, na.rm = TRUE) ) } ``` ```r filter_summary(penguins, species == 'Adelie', bill_length_mm) ``` ``` #> # A tibble: 1 × 3 #> n mean sd #> <int> <dbl> <dbl> #> 1 152 38.8 2.66 ``` --- class: inverse
15
:
00
## Your turn - write the following functions .leftcol[ ```r my_subset <- function(df, condition, cols) ``` Returns a subset of `df` by filtering the rows based on `condition` and only includes the select `cols`. Example: ```r nycflights13::flights %>% my_subset(month == 12, c("carrier", "flight")) ``` ``` #> # A tibble: 5 × 2 #> carrier flight #> <chr> <int> #> 1 B6 745 #> 2 B6 839 #> 3 US 1895 #> 4 UA 1487 #> 5 AA 2243 ``` ] .rightcol[ ```r count_p <- function(df, group) ``` Returns a summary data frame of the count of rows in `df` by `group` as well as the percentage of those counts. ```r nycflights13::flights %>% count_p(carrier) ``` ``` #> # A tibble: 6 × 3 #> carrier n p #> <chr> <int> <dbl> #> 1 UA 58665 0.174 #> 2 B6 54635 0.162 #> 3 EV 54173 0.161 #> 4 DL 48110 0.143 #> 5 AA 32729 0.0972 #> 6 MQ 26397 0.0784 ``` ] --- .leftcol[ ### Testing data frame functions Function: ```r my_summary <- function(df, group, var) { df %>% group_by({{ group }}) %>% summarise( n = n(), mean = mean({{ var }}), sd = sd({{ var }}) ) } ``` ] .rightcol[ Make two data frames and compare them ```r test_my_summary <- function() { cat("Testing my_summary()...") df1 <- diamonds %>% my_summary(cut, price) df2 <- diamonds %>% group_by(cut) %>% summarise( n = n(), mean = mean(price), sd = sd(price) ) * stopifnot(identical(df1, df2)) cat("passed!") } test_my_summary() ``` ``` #> Testing my_summary()...passed! ``` ] --- class: inverse, middle # Week 11: .fancy[Programming with Data] ### 1. Writing functions for data frames ### 2. .orange[Writing custom plot functions] ### BREAK ### 3. Iteration with purrr --- # Motivation I want to see a histogram of multiple variables .leftcol[ ```r diamonds %>% ggplot() + geom_histogram((aes(x = price))) ``` <img src="figs/unnamed-chunk-36-1.png" width="522.144" /> ] .rightcol[ ```r diamonds %>% ggplot() + geom_histogram((aes(x = carat))) ``` <img src="figs/unnamed-chunk-37-1.png" width="522.144" /> ] --- # Convert this to a function ```r my_hist <- function(df, var) { df %>% ggplot() + geom_histogram((aes(x = {{ var }}))) # << } ``` .leftcol[ ```r my_hist(diamonds, price) ``` <img src="figs/unnamed-chunk-39-1.png" width="522.144" /> ] .rightcol[ ```r my_hist(diamonds, carat) ``` <img src="figs/unnamed-chunk-40-1.png" width="522.144" /> ] --- ## Combine with other functions ```r filtered_hist <- function(df, condition, var) { df %>% * filter({{ condition }}) %>% ggplot() + geom_histogram((aes(x = {{ var }}))) } ``` .leftcol[ ```r filtered_hist(diamonds, color == "E", price) ``` <img src="figs/unnamed-chunk-42-1.png" width="522.144" /> ] .rightcol[ ```r filtered_hist(diamonds, color == "J", price) ``` <img src="figs/unnamed-chunk-43-1.png" width="522.144" /> ] --- class: inverse
10
:
00
## Your turn Write the function `filtered_scatter` which plots a scatterplot based on a condition, then use it for the two examples below. ```r filtered_scatter <- function(df, condition, x, y) ``` .leftcol[ ```r filtered_scatter( penguins, sex == "male", x = body_mass_g, y = bill_length_mm) ``` <img src="figs/unnamed-chunk-47-1.png" width="360" /> ] .rightcol[ ```r filtered_scatter( penguins, species == "Gentoo", x = body_mass_g, y = flipper_length_mm) ``` <img src="figs/unnamed-chunk-48-1.png" width="360" /> ] --- ## You can add layers to your custom plot functions ```r filtered_scatter( penguins, species == "Gentoo", x = body_mass_g, y = flipper_length_mm) + * theme_bw() ``` <img src="figs/unnamed-chunk-49-1.png" width="360" /> --- class: inverse, center # .fancy[Break]
05
:
00
--- class: inverse, middle # Week 11: .fancy[Programming with Data] ### 1. Writing functions for data frames ### 2. Writing custom plot functions ### BREAK ### 3. .orange[Iteration with purrr] #### .center[Much of this content is adapted from Shannon Pileggi's workshop at https://github.com/shannonpileggi/iterating-well-with-purrr] --- class: center, middle # Iterating _without_ purrr --- ## Gapminder example ```r library(gapminder) library(tidyverse) head(gapminder) ``` ``` #> # A tibble: 6 × 6 #> country continent year lifeExp pop gdpPercap #> <fct> <fct> <int> <dbl> <int> <dbl> #> 1 Afghanistan Asia 1952 28.8 8425333 779. #> 2 Afghanistan Asia 1957 30.3 9240934 821. #> 3 Afghanistan Asia 1962 32.0 10267083 853. #> 4 Afghanistan Asia 1967 34.0 11537966 836. #> 5 Afghanistan Asia 1972 36.1 13079460 740. #> 6 Afghanistan Asia 1977 38.4 14880372 786. ``` Hans Rosling discusses Gapminder data https://youtu.be/hVimVzgtD6w --- ## Gapminder life expectancy <img src="figs/unnamed-chunk-53-1.png" width="1080" /> --- #### .center[What am I doing here? Are there mistakes?] ```r africa <- gapminder[gapminder$continent == "Africa", ] africa_mm <- max(africa$lifeExp) - min(africa$lifeExp) americas <- gapminder[gapminder$continent == "Americas", ] americas_mm <- max(americas$lifeExp) - min(americas$lifeExp) asia <- gapminder[gapminder$continent == "Asia", ] asia_mm <- max(asia$lifeExp) - min(africa$lifeExp) europe <- gapminder[gapminder$continent == "Europe", ] europe_mm <- max(europe$lifeExp) - min(europe$lifeExp) oceania <- gapminder[gapminder$continent == "Oceania", ] oceania_mm <- max(europe$lifeExp) - min(oceania$lifeExp) cbind( continent = c("Africa", "Asias", "Europe", "Oceania"), max_minus_min = c(africa_mm, americas_mm, asia_mm, europe_mm, oceania_mm) ) ```
01
:
00
--- ### 1. What are the drawbacks of this code? ### 2. How would you do it instead? ```r africa <- gapminder[gapminder$continent == "Africa", ] africa_mm <- max(africa$lifeExp) - min(africa$lifeExp) americas <- gapminder[gapminder$continent == "Americas", ] americas_mm <- max(americas$lifeExp) - min(americas$lifeExp) asia <- gapminder[gapminder$continent == "Asia", ] asia_mm <- max(asia$lifeExp) - min(africa$lifeExp) europe <- gapminder[gapminder$continent == "Europe", ] europe_mm <- max(europe$lifeExp) - min(europe$lifeExp) oceania <- gapminder[gapminder$continent == "Oceania", ] oceania_mm <- max(europe$lifeExp) - min(oceania$lifeExp) cbind( continent = c("Africa", "Asias", "Europe", "Oceania"), max_minus_min = c(africa_mm, americas_mm, asia_mm, europe_mm, oceania_mm) ) ``` --- ## An alternative solution ```r gapminder %>% group_by(continent) %>% summarize(max_minus_min = max(lifeExp) - min(lifeExp)) ``` -- .leftcol[ `group_by` approach ``` #> # A tibble: 5 × 2 #> continent max_minus_min #> <fct> <dbl> #> 1 Africa 52.8 #> 2 Americas 43.1 #> 3 Asia 53.8 #> 4 Europe 38.2 #> 5 Oceania 12.1 ``` ] .rightcol[ previous approach ``` #> continent max_minus_min #> [1,] "Africa" "52.843" #> [2,] "Asias" "43.074" #> [3,] "Europe" "59.004" #> [4,] "Oceania" "38.172" #> [5,] "Africa" "12.637" ``` ] --- ## More iteration ```r year <- 2017:2021 location <- c("Orlando", "San Diego", "Austin", "San Francisco", "remote") conf <- rep("", length(year)) for (i in 1:length(conf)) { conf[i] <- paste0("The ", year[i], " RStudio Conference was in ", location[i], ".") } conf ``` ``` #> [1] "The 2017 RStudio Conference was in Orlando." #> [2] "The 2018 RStudio Conference was in San Diego." #> [3] "The 2019 RStudio Conference was in Austin." #> [4] "The 2020 RStudio Conference was in San Francisco." #> [5] "The 2021 RStudio Conference was in remote." ``` -- #### Can you think of other ways to do this? --- ## More iteration, cont. ```r year <- 2017:2021 location <- c("Orlando", "San Diego", "Austin", "San Francisco", "remote") ``` -- ```r paste0("The ", year, " RStudio Conference was in ", location, ".") ``` ``` #> [1] "The 2017 RStudio Conference was in Orlando." #> [2] "The 2018 RStudio Conference was in San Diego." #> [3] "The 2019 RStudio Conference was in Austin." #> [4] "The 2020 RStudio Conference was in San Francisco." #> [5] "The 2021 RStudio Conference was in remote." ``` -- ```r glue::glue("The {year} RStudio Conference was in {location}.") ``` ``` #> The 2017 RStudio Conference was in Orlando. #> The 2018 RStudio Conference was in San Diego. #> The 2019 RStudio Conference was in Austin. #> The 2020 RStudio Conference was in San Francisco. #> The 2021 RStudio Conference was in remote. ``` --- class: center, middle # Introducing `purrr` <center> <img src="https://purrr.tidyverse.org/logo.png" width=200> </center> Loaded automatically with `library(tidyverse)` --- class: center, middle ## `purrr::map(x, f, ...)` <br> -- ## for every element of `x` do `f` --- background-image: url("images/lego1.jpeg") background-size: contain class: center <br> ## `x = minis` ## `f = add_antenna` --- background-image: url("images/lego2.jpeg") background-size: contain class: center <br> ## `map(minis, add_antenna)` --- class: center ## for every element of `x` do `f` <center> <img src="images/map.png" width=650> </center> --- ## `map()` returns a list Vector example ```r addTen <- function(x) { return(x + 10) } ``` -- ```r map(c(1, 7, 13), addTen) ``` -- ``` #> [[1]] #> [1] 11 #> #> [[2]] #> [1] 17 #> #> [[3]] #> [1] 23 ``` --- ## .center[Working with lists feels like...] <center> <img src="images/drink-water.gif" width=800> </center> .center[https://media.giphy.com/media/Bqn8Z7xdPCFy0/giphy.gif] --- ## .center[Subsetting lists] <center> <img src="images/list-train.png" width=900> </center> .font87[source: https://shannonpileggi.github.io/iterating-well-with-purrr/#/subsetting-lists] --- <center> <img src="images/list-train.png" width=700> </center> .leftcol[ ```r x <- list(c(1, 2, 3), "a", c(4, 5, 6)) ``` ] .rightcol[ ```r x[1] ``` ``` #> [[1]] #> [1] 1 2 3 ``` ```r x[[1]] ``` ``` #> [1] 1 2 3 ``` ] --- # Example data: `sw_people` ```r library(repurrrsive) ``` .leftcol[ ```r sw_people ``` ``` #> [[1]] #> [[1]]$name #> [1] "Luke Skywalker" #> #> [[1]]$height #> [1] "172" #> #> [[1]]$mass #> [1] "77" #> #> [[1]]$hair_color #> [1] "blond" #> #> [[1]]$skin_color #> [1] "fair" #> #> [[1]]$eye_color #> [1] "blue" #> #> [[1]]$birth_year #> [1] "19BBY" #> #> [[1]]$gender #> [1] "male" #> #> [[1]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[1]]$films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> [5] "http://swapi.co/api/films/7/" #> #> [[1]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[1]]$vehicles #> [1] "http://swapi.co/api/vehicles/14/" "http://swapi.co/api/vehicles/30/" #> #> [[1]]$starships #> [1] "http://swapi.co/api/starships/12/" "http://swapi.co/api/starships/22/" #> #> [[1]]$created #> [1] "2014-12-09T13:50:51.644000Z" #> #> [[1]]$edited #> [1] "2014-12-20T21:17:56.891000Z" #> #> [[1]]$url #> [1] "http://swapi.co/api/people/1/" #> #> #> [[2]] #> [[2]]$name #> [1] "C-3PO" #> #> [[2]]$height #> [1] "167" #> #> [[2]]$mass #> [1] "75" #> #> [[2]]$hair_color #> [1] "n/a" #> #> [[2]]$skin_color #> [1] "gold" #> #> [[2]]$eye_color #> [1] "yellow" #> #> [[2]]$birth_year #> [1] "112BBY" #> #> [[2]]$gender #> [1] "n/a" #> #> [[2]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[2]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [5] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> #> [[2]]$species #> [1] "http://swapi.co/api/species/2/" #> #> [[2]]$created #> [1] "2014-12-10T15:10:51.357000Z" #> #> [[2]]$edited #> [1] "2014-12-20T21:17:50.309000Z" #> #> [[2]]$url #> [1] "http://swapi.co/api/people/2/" #> #> #> [[3]] #> [[3]]$name #> [1] "R2-D2" #> #> [[3]]$height #> [1] "96" #> #> [[3]]$mass #> [1] "32" #> #> [[3]]$hair_color #> [1] "n/a" #> #> [[3]]$skin_color #> [1] "white, blue" #> #> [[3]]$eye_color #> [1] "red" #> #> [[3]]$birth_year #> [1] "33BBY" #> #> [[3]]$gender #> [1] "n/a" #> #> [[3]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[3]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [5] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> [7] "http://swapi.co/api/films/7/" #> #> [[3]]$species #> [1] "http://swapi.co/api/species/2/" #> #> [[3]]$created #> [1] "2014-12-10T15:11:50.376000Z" #> #> [[3]]$edited #> [1] "2014-12-20T21:17:50.311000Z" #> #> [[3]]$url #> [1] "http://swapi.co/api/people/3/" #> #> #> [[4]] #> [[4]]$name #> [1] "Darth Vader" #> #> [[4]]$height #> [1] "202" #> #> [[4]]$mass #> [1] "136" #> #> [[4]]$hair_color #> [1] "none" #> #> [[4]]$skin_color #> [1] "white" #> #> [[4]]$eye_color #> [1] "yellow" #> #> [[4]]$birth_year #> [1] "41.9BBY" #> #> [[4]]$gender #> [1] "male" #> #> [[4]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[4]]$films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> #> [[4]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[4]]$starships #> [1] "http://swapi.co/api/starships/13/" #> #> [[4]]$created #> [1] "2014-12-10T15:18:20.704000Z" #> #> [[4]]$edited #> [1] "2014-12-20T21:17:50.313000Z" #> #> [[4]]$url #> [1] "http://swapi.co/api/people/4/" #> #> #> [[5]] #> [[5]]$name #> [1] "Leia Organa" #> #> [[5]]$height #> [1] "150" #> #> [[5]]$mass #> [1] "49" #> #> [[5]]$hair_color #> [1] "brown" #> #> [[5]]$skin_color #> [1] "light" #> #> [[5]]$eye_color #> [1] "brown" #> #> [[5]]$birth_year #> [1] "19BBY" #> #> [[5]]$gender #> [1] "female" #> #> [[5]]$homeworld #> [1] "http://swapi.co/api/planets/2/" #> #> [[5]]$films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> [5] "http://swapi.co/api/films/7/" #> #> [[5]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[5]]$vehicles #> [1] "http://swapi.co/api/vehicles/30/" #> #> [[5]]$created #> [1] "2014-12-10T15:20:09.791000Z" #> #> [[5]]$edited #> [1] "2014-12-20T21:17:50.315000Z" #> #> [[5]]$url #> [1] "http://swapi.co/api/people/5/" #> #> #> [[6]] #> [[6]]$name #> [1] "Owen Lars" #> #> [[6]]$height #> [1] "178" #> #> [[6]]$mass #> [1] "120" #> #> [[6]]$hair_color #> [1] "brown, grey" #> #> [[6]]$skin_color #> [1] "light" #> #> [[6]]$eye_color #> [1] "blue" #> #> [[6]]$birth_year #> [1] "52BBY" #> #> [[6]]$gender #> [1] "male" #> #> [[6]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[6]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> [3] "http://swapi.co/api/films/1/" #> #> [[6]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[6]]$created #> [1] "2014-12-10T15:52:14.024000Z" #> #> [[6]]$edited #> [1] "2014-12-20T21:17:50.317000Z" #> #> [[6]]$url #> [1] "http://swapi.co/api/people/6/" #> #> #> [[7]] #> [[7]]$name #> [1] "Beru Whitesun lars" #> #> [[7]]$height #> [1] "165" #> #> [[7]]$mass #> [1] "75" #> #> [[7]]$hair_color #> [1] "brown" #> #> [[7]]$skin_color #> [1] "light" #> #> [[7]]$eye_color #> [1] "blue" #> #> [[7]]$birth_year #> [1] "47BBY" #> #> [[7]]$gender #> [1] "female" #> #> [[7]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[7]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> [3] "http://swapi.co/api/films/1/" #> #> [[7]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[7]]$created #> [1] "2014-12-10T15:53:41.121000Z" #> #> [[7]]$edited #> [1] "2014-12-20T21:17:50.319000Z" #> #> [[7]]$url #> [1] "http://swapi.co/api/people/7/" #> #> #> [[8]] #> [[8]]$name #> [1] "R5-D4" #> #> [[8]]$height #> [1] "97" #> #> [[8]]$mass #> [1] "32" #> #> [[8]]$hair_color #> [1] "n/a" #> #> [[8]]$skin_color #> [1] "white, red" #> #> [[8]]$eye_color #> [1] "red" #> #> [[8]]$birth_year #> [1] "unknown" #> #> [[8]]$gender #> [1] "n/a" #> #> [[8]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[8]]$films #> [1] "http://swapi.co/api/films/1/" #> #> [[8]]$species #> [1] "http://swapi.co/api/species/2/" #> #> [[8]]$created #> [1] "2014-12-10T15:57:50.959000Z" #> #> [[8]]$edited #> [1] "2014-12-20T21:17:50.321000Z" #> #> [[8]]$url #> [1] "http://swapi.co/api/people/8/" #> #> #> [[9]] #> [[9]]$name #> [1] "Biggs Darklighter" #> #> [[9]]$height #> [1] "183" #> #> [[9]]$mass #> [1] "84" #> #> [[9]]$hair_color #> [1] "black" #> #> [[9]]$skin_color #> [1] "light" #> #> [[9]]$eye_color #> [1] "brown" #> #> [[9]]$birth_year #> [1] "24BBY" #> #> [[9]]$gender #> [1] "male" #> #> [[9]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[9]]$films #> [1] "http://swapi.co/api/films/1/" #> #> [[9]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[9]]$starships #> [1] "http://swapi.co/api/starships/12/" #> #> [[9]]$created #> [1] "2014-12-10T15:59:50.509000Z" #> #> [[9]]$edited #> [1] "2014-12-20T21:17:50.323000Z" #> #> [[9]]$url #> [1] "http://swapi.co/api/people/9/" #> #> #> [[10]] #> [[10]]$name #> [1] "Obi-Wan Kenobi" #> #> [[10]]$height #> [1] "182" #> #> [[10]]$mass #> [1] "77" #> #> [[10]]$hair_color #> [1] "auburn, white" #> #> [[10]]$skin_color #> [1] "fair" #> #> [[10]]$eye_color #> [1] "blue-gray" #> #> [[10]]$birth_year #> [1] "57BBY" #> #> [[10]]$gender #> [1] "male" #> #> [[10]]$homeworld #> [1] "http://swapi.co/api/planets/20/" #> #> [[10]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [5] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> #> [[10]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[10]]$vehicles #> [1] "http://swapi.co/api/vehicles/38/" #> #> [[10]]$starships #> [1] "http://swapi.co/api/starships/48/" "http://swapi.co/api/starships/59/" #> [3] "http://swapi.co/api/starships/64/" "http://swapi.co/api/starships/65/" #> [5] "http://swapi.co/api/starships/74/" #> #> [[10]]$created #> [1] "2014-12-10T16:16:29.192000Z" #> #> [[10]]$edited #> [1] "2014-12-20T21:17:50.325000Z" #> #> [[10]]$url #> [1] "http://swapi.co/api/people/10/" #> #> #> [[11]] #> [[11]]$name #> [1] "Anakin Skywalker" #> #> [[11]]$height #> [1] "188" #> #> [[11]]$mass #> [1] "84" #> #> [[11]]$hair_color #> [1] "blond" #> #> [[11]]$skin_color #> [1] "fair" #> #> [[11]]$eye_color #> [1] "blue" #> #> [[11]]$birth_year #> [1] "41.9BBY" #> #> [[11]]$gender #> [1] "male" #> #> [[11]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[11]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[11]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[11]]$vehicles #> [1] "http://swapi.co/api/vehicles/44/" "http://swapi.co/api/vehicles/46/" #> #> [[11]]$starships #> [1] "http://swapi.co/api/starships/59/" "http://swapi.co/api/starships/65/" #> [3] "http://swapi.co/api/starships/39/" #> #> [[11]]$created #> [1] "2014-12-10T16:20:44.310000Z" #> #> [[11]]$edited #> [1] "2014-12-20T21:17:50.327000Z" #> #> [[11]]$url #> [1] "http://swapi.co/api/people/11/" #> #> #> [[12]] #> [[12]]$name #> [1] "Wilhuff Tarkin" #> #> [[12]]$height #> [1] "180" #> #> [[12]]$mass #> [1] "unknown" #> #> [[12]]$hair_color #> [1] "auburn, grey" #> #> [[12]]$skin_color #> [1] "fair" #> #> [[12]]$eye_color #> [1] "blue" #> #> [[12]]$birth_year #> [1] "64BBY" #> #> [[12]]$gender #> [1] "male" #> #> [[12]]$homeworld #> [1] "http://swapi.co/api/planets/21/" #> #> [[12]]$films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/1/" #> #> [[12]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[12]]$created #> [1] "2014-12-10T16:26:56.138000Z" #> #> [[12]]$edited #> [1] "2014-12-20T21:17:50.330000Z" #> #> [[12]]$url #> [1] "http://swapi.co/api/people/12/" #> #> #> [[13]] #> [[13]]$name #> [1] "Chewbacca" #> #> [[13]]$height #> [1] "228" #> #> [[13]]$mass #> [1] "112" #> #> [[13]]$hair_color #> [1] "brown" #> #> [[13]]$skin_color #> [1] "unknown" #> #> [[13]]$eye_color #> [1] "blue" #> #> [[13]]$birth_year #> [1] "200BBY" #> #> [[13]]$gender #> [1] "male" #> #> [[13]]$homeworld #> [1] "http://swapi.co/api/planets/14/" #> #> [[13]]$films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> [5] "http://swapi.co/api/films/7/" #> #> [[13]]$species #> [1] "http://swapi.co/api/species/3/" #> #> [[13]]$vehicles #> [1] "http://swapi.co/api/vehicles/19/" #> #> [[13]]$starships #> [1] "http://swapi.co/api/starships/10/" "http://swapi.co/api/starships/22/" #> #> [[13]]$created #> [1] "2014-12-10T16:42:45.066000Z" #> #> [[13]]$edited #> [1] "2014-12-20T21:17:50.332000Z" #> #> [[13]]$url #> [1] "http://swapi.co/api/people/13/" #> #> #> [[14]] #> [[14]]$name #> [1] "Han Solo" #> #> [[14]]$height #> [1] "180" #> #> [[14]]$mass #> [1] "80" #> #> [[14]]$hair_color #> [1] "brown" #> #> [[14]]$skin_color #> [1] "fair" #> #> [[14]]$eye_color #> [1] "brown" #> #> [[14]]$birth_year #> [1] "29BBY" #> #> [[14]]$gender #> [1] "male" #> #> [[14]]$homeworld #> [1] "http://swapi.co/api/planets/22/" #> #> [[14]]$films #> [1] "http://swapi.co/api/films/3/" "http://swapi.co/api/films/2/" #> [3] "http://swapi.co/api/films/1/" "http://swapi.co/api/films/7/" #> #> [[14]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[14]]$starships #> [1] "http://swapi.co/api/starships/10/" "http://swapi.co/api/starships/22/" #> #> [[14]]$created #> [1] "2014-12-10T16:49:14.582000Z" #> #> [[14]]$edited #> [1] "2014-12-20T21:17:50.334000Z" #> #> [[14]]$url #> [1] "http://swapi.co/api/people/14/" #> #> #> [[15]] #> [[15]]$name #> [1] "Greedo" #> #> [[15]]$height #> [1] "173" #> #> [[15]]$mass #> [1] "74" #> #> [[15]]$hair_color #> [1] "n/a" #> #> [[15]]$skin_color #> [1] "green" #> #> [[15]]$eye_color #> [1] "black" #> #> [[15]]$birth_year #> [1] "44BBY" #> #> [[15]]$gender #> [1] "male" #> #> [[15]]$homeworld #> [1] "http://swapi.co/api/planets/23/" #> #> [[15]]$films #> [1] "http://swapi.co/api/films/1/" #> #> [[15]]$species #> [1] "http://swapi.co/api/species/4/" #> #> [[15]]$created #> [1] "2014-12-10T17:03:30.334000Z" #> #> [[15]]$edited #> [1] "2014-12-20T21:17:50.336000Z" #> #> [[15]]$url #> [1] "http://swapi.co/api/people/15/" #> #> #> [[16]] #> [[16]]$name #> [1] "Jabba Desilijic Tiure" #> #> [[16]]$height #> [1] "175" #> #> [[16]]$mass #> [1] "1,358" #> #> [[16]]$hair_color #> [1] "n/a" #> #> [[16]]$skin_color #> [1] "green-tan, brown" #> #> [[16]]$eye_color #> [1] "orange" #> #> [[16]]$birth_year #> [1] "600BBY" #> #> [[16]]$gender #> [1] "hermaphrodite" #> #> [[16]]$homeworld #> [1] "http://swapi.co/api/planets/24/" #> #> [[16]]$films #> [1] "http://swapi.co/api/films/4/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/1/" #> #> [[16]]$species #> [1] "http://swapi.co/api/species/5/" #> #> [[16]]$created #> [1] "2014-12-10T17:11:31.638000Z" #> #> [[16]]$edited #> [1] "2014-12-20T21:17:50.338000Z" #> #> [[16]]$url #> [1] "http://swapi.co/api/people/16/" #> #> #> [[17]] #> [[17]]$name #> [1] "Wedge Antilles" #> #> [[17]]$height #> [1] "170" #> #> [[17]]$mass #> [1] "77" #> #> [[17]]$hair_color #> [1] "brown" #> #> [[17]]$skin_color #> [1] "fair" #> #> [[17]]$eye_color #> [1] "hazel" #> #> [[17]]$birth_year #> [1] "21BBY" #> #> [[17]]$gender #> [1] "male" #> #> [[17]]$homeworld #> [1] "http://swapi.co/api/planets/22/" #> #> [[17]]$films #> [1] "http://swapi.co/api/films/3/" "http://swapi.co/api/films/2/" #> [3] "http://swapi.co/api/films/1/" #> #> [[17]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[17]]$vehicles #> [1] "http://swapi.co/api/vehicles/14/" #> #> [[17]]$starships #> [1] "http://swapi.co/api/starships/12/" #> #> [[17]]$created #> [1] "2014-12-12T11:08:06.469000Z" #> #> [[17]]$edited #> [1] "2014-12-20T21:17:50.341000Z" #> #> [[17]]$url #> [1] "http://swapi.co/api/people/18/" #> #> #> [[18]] #> [[18]]$name #> [1] "Jek Tono Porkins" #> #> [[18]]$height #> [1] "180" #> #> [[18]]$mass #> [1] "110" #> #> [[18]]$hair_color #> [1] "brown" #> #> [[18]]$skin_color #> [1] "fair" #> #> [[18]]$eye_color #> [1] "blue" #> #> [[18]]$birth_year #> [1] "unknown" #> #> [[18]]$gender #> [1] "male" #> #> [[18]]$homeworld #> [1] "http://swapi.co/api/planets/26/" #> #> [[18]]$films #> [1] "http://swapi.co/api/films/1/" #> #> [[18]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[18]]$starships #> [1] "http://swapi.co/api/starships/12/" #> #> [[18]]$created #> [1] "2014-12-12T11:16:56.569000Z" #> #> [[18]]$edited #> [1] "2014-12-20T21:17:50.343000Z" #> #> [[18]]$url #> [1] "http://swapi.co/api/people/19/" #> #> #> [[19]] #> [[19]]$name #> [1] "Yoda" #> #> [[19]]$height #> [1] "66" #> #> [[19]]$mass #> [1] "17" #> #> [[19]]$hair_color #> [1] "white" #> #> [[19]]$skin_color #> [1] "green" #> #> [[19]]$eye_color #> [1] "brown" #> #> [[19]]$birth_year #> [1] "896BBY" #> #> [[19]]$gender #> [1] "male" #> #> [[19]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[19]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [5] "http://swapi.co/api/films/2/" #> #> [[19]]$species #> [1] "http://swapi.co/api/species/6/" #> #> [[19]]$created #> [1] "2014-12-15T12:26:01.042000Z" #> #> [[19]]$edited #> [1] "2014-12-20T21:17:50.345000Z" #> #> [[19]]$url #> [1] "http://swapi.co/api/people/20/" #> #> #> [[20]] #> [[20]]$name #> [1] "Palpatine" #> #> [[20]]$height #> [1] "170" #> #> [[20]]$mass #> [1] "75" #> #> [[20]]$hair_color #> [1] "grey" #> #> [[20]]$skin_color #> [1] "pale" #> #> [[20]]$eye_color #> [1] "yellow" #> #> [[20]]$birth_year #> [1] "82BBY" #> #> [[20]]$gender #> [1] "male" #> #> [[20]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[20]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [5] "http://swapi.co/api/films/2/" #> #> [[20]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[20]]$created #> [1] "2014-12-15T12:48:05.971000Z" #> #> [[20]]$edited #> [1] "2014-12-20T21:17:50.347000Z" #> #> [[20]]$url #> [1] "http://swapi.co/api/people/21/" #> #> #> [[21]] #> [[21]]$name #> [1] "Boba Fett" #> #> [[21]]$height #> [1] "183" #> #> [[21]]$mass #> [1] "78.2" #> #> [[21]]$hair_color #> [1] "black" #> #> [[21]]$skin_color #> [1] "fair" #> #> [[21]]$eye_color #> [1] "brown" #> #> [[21]]$birth_year #> [1] "31.5BBY" #> #> [[21]]$gender #> [1] "male" #> #> [[21]]$homeworld #> [1] "http://swapi.co/api/planets/10/" #> #> [[21]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" #> #> [[21]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[21]]$starships #> [1] "http://swapi.co/api/starships/21/" #> #> [[21]]$created #> [1] "2014-12-15T12:49:32.457000Z" #> #> [[21]]$edited #> [1] "2014-12-20T21:17:50.349000Z" #> #> [[21]]$url #> [1] "http://swapi.co/api/people/22/" #> #> #> [[22]] #> [[22]]$name #> [1] "IG-88" #> #> [[22]]$height #> [1] "200" #> #> [[22]]$mass #> [1] "140" #> #> [[22]]$hair_color #> [1] "none" #> #> [[22]]$skin_color #> [1] "metal" #> #> [[22]]$eye_color #> [1] "red" #> #> [[22]]$birth_year #> [1] "15BBY" #> #> [[22]]$gender #> [1] "none" #> #> [[22]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[22]]$films #> [1] "http://swapi.co/api/films/2/" #> #> [[22]]$species #> [1] "http://swapi.co/api/species/2/" #> #> [[22]]$created #> [1] "2014-12-15T12:51:10.076000Z" #> #> [[22]]$edited #> [1] "2014-12-20T21:17:50.351000Z" #> #> [[22]]$url #> [1] "http://swapi.co/api/people/23/" #> #> #> [[23]] #> [[23]]$name #> [1] "Bossk" #> #> [[23]]$height #> [1] "190" #> #> [[23]]$mass #> [1] "113" #> #> [[23]]$hair_color #> [1] "none" #> #> [[23]]$skin_color #> [1] "green" #> #> [[23]]$eye_color #> [1] "red" #> #> [[23]]$birth_year #> [1] "53BBY" #> #> [[23]]$gender #> [1] "male" #> #> [[23]]$homeworld #> [1] "http://swapi.co/api/planets/29/" #> #> [[23]]$films #> [1] "http://swapi.co/api/films/2/" #> #> [[23]]$species #> [1] "http://swapi.co/api/species/7/" #> #> [[23]]$created #> [1] "2014-12-15T12:53:49.297000Z" #> #> [[23]]$edited #> [1] "2014-12-20T21:17:50.355000Z" #> #> [[23]]$url #> [1] "http://swapi.co/api/people/24/" #> #> #> [[24]] #> [[24]]$name #> [1] "Lando Calrissian" #> #> [[24]]$height #> [1] "177" #> #> [[24]]$mass #> [1] "79" #> #> [[24]]$hair_color #> [1] "black" #> #> [[24]]$skin_color #> [1] "dark" #> #> [[24]]$eye_color #> [1] "brown" #> #> [[24]]$birth_year #> [1] "31BBY" #> #> [[24]]$gender #> [1] "male" #> #> [[24]]$homeworld #> [1] "http://swapi.co/api/planets/30/" #> #> [[24]]$films #> [1] "http://swapi.co/api/films/3/" "http://swapi.co/api/films/2/" #> #> [[24]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[24]]$starships #> [1] "http://swapi.co/api/starships/10/" #> #> [[24]]$created #> [1] "2014-12-15T12:56:32.683000Z" #> #> [[24]]$edited #> [1] "2014-12-20T21:17:50.357000Z" #> #> [[24]]$url #> [1] "http://swapi.co/api/people/25/" #> #> #> [[25]] #> [[25]]$name #> [1] "Lobot" #> #> [[25]]$height #> [1] "175" #> #> [[25]]$mass #> [1] "79" #> #> [[25]]$hair_color #> [1] "none" #> #> [[25]]$skin_color #> [1] "light" #> #> [[25]]$eye_color #> [1] "blue" #> #> [[25]]$birth_year #> [1] "37BBY" #> #> [[25]]$gender #> [1] "male" #> #> [[25]]$homeworld #> [1] "http://swapi.co/api/planets/6/" #> #> [[25]]$films #> [1] "http://swapi.co/api/films/2/" #> #> [[25]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[25]]$created #> [1] "2014-12-15T13:01:57.178000Z" #> #> [[25]]$edited #> [1] "2014-12-20T21:17:50.359000Z" #> #> [[25]]$url #> [1] "http://swapi.co/api/people/26/" #> #> #> [[26]] #> [[26]]$name #> [1] "Ackbar" #> #> [[26]]$height #> [1] "180" #> #> [[26]]$mass #> [1] "83" #> #> [[26]]$hair_color #> [1] "none" #> #> [[26]]$skin_color #> [1] "brown mottle" #> #> [[26]]$eye_color #> [1] "orange" #> #> [[26]]$birth_year #> [1] "41BBY" #> #> [[26]]$gender #> [1] "male" #> #> [[26]]$homeworld #> [1] "http://swapi.co/api/planets/31/" #> #> [[26]]$films #> [1] "http://swapi.co/api/films/3/" "http://swapi.co/api/films/7/" #> #> [[26]]$species #> [1] "http://swapi.co/api/species/8/" #> #> [[26]]$created #> [1] "2014-12-18T11:07:50.584000Z" #> #> [[26]]$edited #> [1] "2014-12-20T21:17:50.362000Z" #> #> [[26]]$url #> [1] "http://swapi.co/api/people/27/" #> #> #> [[27]] #> [[27]]$name #> [1] "Mon Mothma" #> #> [[27]]$height #> [1] "150" #> #> [[27]]$mass #> [1] "unknown" #> #> [[27]]$hair_color #> [1] "auburn" #> #> [[27]]$skin_color #> [1] "fair" #> #> [[27]]$eye_color #> [1] "blue" #> #> [[27]]$birth_year #> [1] "48BBY" #> #> [[27]]$gender #> [1] "female" #> #> [[27]]$homeworld #> [1] "http://swapi.co/api/planets/32/" #> #> [[27]]$films #> [1] "http://swapi.co/api/films/3/" #> #> [[27]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[27]]$created #> [1] "2014-12-18T11:12:38.895000Z" #> #> [[27]]$edited #> [1] "2014-12-20T21:17:50.364000Z" #> #> [[27]]$url #> [1] "http://swapi.co/api/people/28/" #> #> #> [[28]] #> [[28]]$name #> [1] "Arvel Crynyd" #> #> [[28]]$height #> [1] "unknown" #> #> [[28]]$mass #> [1] "unknown" #> #> [[28]]$hair_color #> [1] "brown" #> #> [[28]]$skin_color #> [1] "fair" #> #> [[28]]$eye_color #> [1] "brown" #> #> [[28]]$birth_year #> [1] "unknown" #> #> [[28]]$gender #> [1] "male" #> #> [[28]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[28]]$films #> [1] "http://swapi.co/api/films/3/" #> #> [[28]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[28]]$starships #> [1] "http://swapi.co/api/starships/28/" #> #> [[28]]$created #> [1] "2014-12-18T11:16:33.020000Z" #> #> [[28]]$edited #> [1] "2014-12-20T21:17:50.367000Z" #> #> [[28]]$url #> [1] "http://swapi.co/api/people/29/" #> #> #> [[29]] #> [[29]]$name #> [1] "Wicket Systri Warrick" #> #> [[29]]$height #> [1] "88" #> #> [[29]]$mass #> [1] "20" #> #> [[29]]$hair_color #> [1] "brown" #> #> [[29]]$skin_color #> [1] "brown" #> #> [[29]]$eye_color #> [1] "brown" #> #> [[29]]$birth_year #> [1] "8BBY" #> #> [[29]]$gender #> [1] "male" #> #> [[29]]$homeworld #> [1] "http://swapi.co/api/planets/7/" #> #> [[29]]$films #> [1] "http://swapi.co/api/films/3/" #> #> [[29]]$species #> [1] "http://swapi.co/api/species/9/" #> #> [[29]]$created #> [1] "2014-12-18T11:21:58.954000Z" #> #> [[29]]$edited #> [1] "2014-12-20T21:17:50.369000Z" #> #> [[29]]$url #> [1] "http://swapi.co/api/people/30/" #> #> #> [[30]] #> [[30]]$name #> [1] "Nien Nunb" #> #> [[30]]$height #> [1] "160" #> #> [[30]]$mass #> [1] "68" #> #> [[30]]$hair_color #> [1] "none" #> #> [[30]]$skin_color #> [1] "grey" #> #> [[30]]$eye_color #> [1] "black" #> #> [[30]]$birth_year #> [1] "unknown" #> #> [[30]]$gender #> [1] "male" #> #> [[30]]$homeworld #> [1] "http://swapi.co/api/planets/33/" #> #> [[30]]$films #> [1] "http://swapi.co/api/films/3/" #> #> [[30]]$species #> [1] "http://swapi.co/api/species/10/" #> #> [[30]]$starships #> [1] "http://swapi.co/api/starships/10/" #> #> [[30]]$created #> [1] "2014-12-18T11:26:18.541000Z" #> #> [[30]]$edited #> [1] "2014-12-20T21:17:50.371000Z" #> #> [[30]]$url #> [1] "http://swapi.co/api/people/31/" #> #> #> [[31]] #> [[31]]$name #> [1] "Qui-Gon Jinn" #> #> [[31]]$height #> [1] "193" #> #> [[31]]$mass #> [1] "89" #> #> [[31]]$hair_color #> [1] "brown" #> #> [[31]]$skin_color #> [1] "fair" #> #> [[31]]$eye_color #> [1] "blue" #> #> [[31]]$birth_year #> [1] "92BBY" #> #> [[31]]$gender #> [1] "male" #> #> [[31]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[31]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[31]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[31]]$vehicles #> [1] "http://swapi.co/api/vehicles/38/" #> #> [[31]]$created #> [1] "2014-12-19T16:54:53.618000Z" #> #> [[31]]$edited #> [1] "2014-12-20T21:17:50.375000Z" #> #> [[31]]$url #> [1] "http://swapi.co/api/people/32/" #> #> #> [[32]] #> [[32]]$name #> [1] "Nute Gunray" #> #> [[32]]$height #> [1] "191" #> #> [[32]]$mass #> [1] "90" #> #> [[32]]$hair_color #> [1] "none" #> #> [[32]]$skin_color #> [1] "mottled green" #> #> [[32]]$eye_color #> [1] "red" #> #> [[32]]$birth_year #> [1] "unknown" #> #> [[32]]$gender #> [1] "male" #> #> [[32]]$homeworld #> [1] "http://swapi.co/api/planets/18/" #> #> [[32]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[32]]$species #> [1] "http://swapi.co/api/species/11/" #> #> [[32]]$created #> [1] "2014-12-19T17:05:57.357000Z" #> #> [[32]]$edited #> [1] "2014-12-20T21:17:50.377000Z" #> #> [[32]]$url #> [1] "http://swapi.co/api/people/33/" #> #> #> [[33]] #> [[33]]$name #> [1] "Finis Valorum" #> #> [[33]]$height #> [1] "170" #> #> [[33]]$mass #> [1] "unknown" #> #> [[33]]$hair_color #> [1] "blond" #> #> [[33]]$skin_color #> [1] "fair" #> #> [[33]]$eye_color #> [1] "blue" #> #> [[33]]$birth_year #> [1] "91BBY" #> #> [[33]]$gender #> [1] "male" #> #> [[33]]$homeworld #> [1] "http://swapi.co/api/planets/9/" #> #> [[33]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[33]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[33]]$created #> [1] "2014-12-19T17:21:45.915000Z" #> #> [[33]]$edited #> [1] "2014-12-20T21:17:50.379000Z" #> #> [[33]]$url #> [1] "http://swapi.co/api/people/34/" #> #> #> [[34]] #> [[34]]$name #> [1] "Jar Jar Binks" #> #> [[34]]$height #> [1] "196" #> #> [[34]]$mass #> [1] "66" #> #> [[34]]$hair_color #> [1] "none" #> #> [[34]]$skin_color #> [1] "orange" #> #> [[34]]$eye_color #> [1] "orange" #> #> [[34]]$birth_year #> [1] "52BBY" #> #> [[34]]$gender #> [1] "male" #> #> [[34]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[34]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> #> [[34]]$species #> [1] "http://swapi.co/api/species/12/" #> #> [[34]]$created #> [1] "2014-12-19T17:29:32.489000Z" #> #> [[34]]$edited #> [1] "2014-12-20T21:17:50.383000Z" #> #> [[34]]$url #> [1] "http://swapi.co/api/people/36/" #> #> #> [[35]] #> [[35]]$name #> [1] "Roos Tarpals" #> #> [[35]]$height #> [1] "224" #> #> [[35]]$mass #> [1] "82" #> #> [[35]]$hair_color #> [1] "none" #> #> [[35]]$skin_color #> [1] "grey" #> #> [[35]]$eye_color #> [1] "orange" #> #> [[35]]$birth_year #> [1] "unknown" #> #> [[35]]$gender #> [1] "male" #> #> [[35]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[35]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[35]]$species #> [1] "http://swapi.co/api/species/12/" #> #> [[35]]$created #> [1] "2014-12-19T17:32:56.741000Z" #> #> [[35]]$edited #> [1] "2014-12-20T21:17:50.385000Z" #> #> [[35]]$url #> [1] "http://swapi.co/api/people/37/" #> #> #> [[36]] #> [[36]]$name #> [1] "Rugor Nass" #> #> [[36]]$height #> [1] "206" #> #> [[36]]$mass #> [1] "unknown" #> #> [[36]]$hair_color #> [1] "none" #> #> [[36]]$skin_color #> [1] "green" #> #> [[36]]$eye_color #> [1] "orange" #> #> [[36]]$birth_year #> [1] "unknown" #> #> [[36]]$gender #> [1] "male" #> #> [[36]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[36]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[36]]$species #> [1] "http://swapi.co/api/species/12/" #> #> [[36]]$created #> [1] "2014-12-19T17:33:38.909000Z" #> #> [[36]]$edited #> [1] "2014-12-20T21:17:50.388000Z" #> #> [[36]]$url #> [1] "http://swapi.co/api/people/38/" #> #> #> [[37]] #> [[37]]$name #> [1] "Ric Olié" #> #> [[37]]$height #> [1] "183" #> #> [[37]]$mass #> [1] "unknown" #> #> [[37]]$hair_color #> [1] "brown" #> #> [[37]]$skin_color #> [1] "fair" #> #> [[37]]$eye_color #> [1] "blue" #> #> [[37]]$birth_year #> [1] "unknown" #> #> [[37]]$gender #> [1] "male" #> #> [[37]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[37]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[37]]$starships #> [1] "http://swapi.co/api/starships/40/" #> #> [[37]]$created #> [1] "2014-12-19T17:45:01.522000Z" #> #> [[37]]$edited #> [1] "2014-12-20T21:17:50.392000Z" #> #> [[37]]$url #> [1] "http://swapi.co/api/people/39/" #> #> #> [[38]] #> [[38]]$name #> [1] "Watto" #> #> [[38]]$height #> [1] "137" #> #> [[38]]$mass #> [1] "unknown" #> #> [[38]]$hair_color #> [1] "black" #> #> [[38]]$skin_color #> [1] "blue, grey" #> #> [[38]]$eye_color #> [1] "yellow" #> #> [[38]]$birth_year #> [1] "unknown" #> #> [[38]]$gender #> [1] "male" #> #> [[38]]$homeworld #> [1] "http://swapi.co/api/planets/34/" #> #> [[38]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> #> [[38]]$species #> [1] "http://swapi.co/api/species/13/" #> #> [[38]]$created #> [1] "2014-12-19T17:48:54.647000Z" #> #> [[38]]$edited #> [1] "2014-12-20T21:17:50.395000Z" #> #> [[38]]$url #> [1] "http://swapi.co/api/people/40/" #> #> #> [[39]] #> [[39]]$name #> [1] "Sebulba" #> #> [[39]]$height #> [1] "112" #> #> [[39]]$mass #> [1] "40" #> #> [[39]]$hair_color #> [1] "none" #> #> [[39]]$skin_color #> [1] "grey, red" #> #> [[39]]$eye_color #> [1] "orange" #> #> [[39]]$birth_year #> [1] "unknown" #> #> [[39]]$gender #> [1] "male" #> #> [[39]]$homeworld #> [1] "http://swapi.co/api/planets/35/" #> #> [[39]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[39]]$species #> [1] "http://swapi.co/api/species/14/" #> #> [[39]]$created #> [1] "2014-12-19T17:53:02.586000Z" #> #> [[39]]$edited #> [1] "2014-12-20T21:17:50.397000Z" #> #> [[39]]$url #> [1] "http://swapi.co/api/people/41/" #> #> #> [[40]] #> [[40]]$name #> [1] "Quarsh Panaka" #> #> [[40]]$height #> [1] "183" #> #> [[40]]$mass #> [1] "unknown" #> #> [[40]]$hair_color #> [1] "black" #> #> [[40]]$skin_color #> [1] "dark" #> #> [[40]]$eye_color #> [1] "brown" #> #> [[40]]$birth_year #> [1] "62BBY" #> #> [[40]]$gender #> [1] "male" #> #> [[40]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[40]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[40]]$created #> [1] "2014-12-19T17:55:43.348000Z" #> #> [[40]]$edited #> [1] "2014-12-20T21:17:50.399000Z" #> #> [[40]]$url #> [1] "http://swapi.co/api/people/42/" #> #> #> [[41]] #> [[41]]$name #> [1] "Shmi Skywalker" #> #> [[41]]$height #> [1] "163" #> #> [[41]]$mass #> [1] "unknown" #> #> [[41]]$hair_color #> [1] "black" #> #> [[41]]$skin_color #> [1] "fair" #> #> [[41]]$eye_color #> [1] "brown" #> #> [[41]]$birth_year #> [1] "72BBY" #> #> [[41]]$gender #> [1] "female" #> #> [[41]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[41]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> #> [[41]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[41]]$created #> [1] "2014-12-19T17:57:41.191000Z" #> #> [[41]]$edited #> [1] "2014-12-20T21:17:50.401000Z" #> #> [[41]]$url #> [1] "http://swapi.co/api/people/43/" #> #> #> [[42]] #> [[42]]$name #> [1] "Darth Maul" #> #> [[42]]$height #> [1] "175" #> #> [[42]]$mass #> [1] "80" #> #> [[42]]$hair_color #> [1] "none" #> #> [[42]]$skin_color #> [1] "red" #> #> [[42]]$eye_color #> [1] "yellow" #> #> [[42]]$birth_year #> [1] "54BBY" #> #> [[42]]$gender #> [1] "male" #> #> [[42]]$homeworld #> [1] "http://swapi.co/api/planets/36/" #> #> [[42]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[42]]$species #> [1] "http://swapi.co/api/species/22/" #> #> [[42]]$vehicles #> [1] "http://swapi.co/api/vehicles/42/" #> #> [[42]]$starships #> [1] "http://swapi.co/api/starships/41/" #> #> [[42]]$created #> [1] "2014-12-19T18:00:41.929000Z" #> #> [[42]]$edited #> [1] "2014-12-20T21:17:50.403000Z" #> #> [[42]]$url #> [1] "http://swapi.co/api/people/44/" #> #> #> [[43]] #> [[43]]$name #> [1] "Bib Fortuna" #> #> [[43]]$height #> [1] "180" #> #> [[43]]$mass #> [1] "unknown" #> #> [[43]]$hair_color #> [1] "none" #> #> [[43]]$skin_color #> [1] "pale" #> #> [[43]]$eye_color #> [1] "pink" #> #> [[43]]$birth_year #> [1] "unknown" #> #> [[43]]$gender #> [1] "male" #> #> [[43]]$homeworld #> [1] "http://swapi.co/api/planets/37/" #> #> [[43]]$films #> [1] "http://swapi.co/api/films/3/" #> #> [[43]]$species #> [1] "http://swapi.co/api/species/15/" #> #> [[43]]$created #> [1] "2014-12-20T09:47:02.512000Z" #> #> [[43]]$edited #> [1] "2014-12-20T21:17:50.407000Z" #> #> [[43]]$url #> [1] "http://swapi.co/api/people/45/" #> #> #> [[44]] #> [[44]]$name #> [1] "Ayla Secura" #> #> [[44]]$height #> [1] "178" #> #> [[44]]$mass #> [1] "55" #> #> [[44]]$hair_color #> [1] "none" #> #> [[44]]$skin_color #> [1] "blue" #> #> [[44]]$eye_color #> [1] "hazel" #> #> [[44]]$birth_year #> [1] "48BBY" #> #> [[44]]$gender #> [1] "female" #> #> [[44]]$homeworld #> [1] "http://swapi.co/api/planets/37/" #> #> [[44]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[44]]$species #> [1] "http://swapi.co/api/species/15/" #> #> [[44]]$created #> [1] "2014-12-20T09:48:01.172000Z" #> #> [[44]]$edited #> [1] "2014-12-20T21:17:50.409000Z" #> #> [[44]]$url #> [1] "http://swapi.co/api/people/46/" #> #> #> [[45]] #> [[45]]$name #> [1] "Dud Bolt" #> #> [[45]]$height #> [1] "94" #> #> [[45]]$mass #> [1] "45" #> #> [[45]]$hair_color #> [1] "none" #> #> [[45]]$skin_color #> [1] "blue, grey" #> #> [[45]]$eye_color #> [1] "yellow" #> #> [[45]]$birth_year #> [1] "unknown" #> #> [[45]]$gender #> [1] "male" #> #> [[45]]$homeworld #> [1] "http://swapi.co/api/planets/39/" #> #> [[45]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[45]]$species #> [1] "http://swapi.co/api/species/17/" #> #> [[45]]$created #> [1] "2014-12-20T09:57:31.858000Z" #> #> [[45]]$edited #> [1] "2014-12-20T21:17:50.414000Z" #> #> [[45]]$url #> [1] "http://swapi.co/api/people/48/" #> #> #> [[46]] #> [[46]]$name #> [1] "Gasgano" #> #> [[46]]$height #> [1] "122" #> #> [[46]]$mass #> [1] "unknown" #> #> [[46]]$hair_color #> [1] "none" #> #> [[46]]$skin_color #> [1] "white, blue" #> #> [[46]]$eye_color #> [1] "black" #> #> [[46]]$birth_year #> [1] "unknown" #> #> [[46]]$gender #> [1] "male" #> #> [[46]]$homeworld #> [1] "http://swapi.co/api/planets/40/" #> #> [[46]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[46]]$species #> [1] "http://swapi.co/api/species/18/" #> #> [[46]]$created #> [1] "2014-12-20T10:02:12.223000Z" #> #> [[46]]$edited #> [1] "2014-12-20T21:17:50.416000Z" #> #> [[46]]$url #> [1] "http://swapi.co/api/people/49/" #> #> #> [[47]] #> [[47]]$name #> [1] "Ben Quadinaros" #> #> [[47]]$height #> [1] "163" #> #> [[47]]$mass #> [1] "65" #> #> [[47]]$hair_color #> [1] "none" #> #> [[47]]$skin_color #> [1] "grey, green, yellow" #> #> [[47]]$eye_color #> [1] "orange" #> #> [[47]]$birth_year #> [1] "unknown" #> #> [[47]]$gender #> [1] "male" #> #> [[47]]$homeworld #> [1] "http://swapi.co/api/planets/41/" #> #> [[47]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[47]]$species #> [1] "http://swapi.co/api/species/19/" #> #> [[47]]$created #> [1] "2014-12-20T10:08:33.777000Z" #> #> [[47]]$edited #> [1] "2014-12-20T21:17:50.417000Z" #> #> [[47]]$url #> [1] "http://swapi.co/api/people/50/" #> #> #> [[48]] #> [[48]]$name #> [1] "Mace Windu" #> #> [[48]]$height #> [1] "188" #> #> [[48]]$mass #> [1] "84" #> #> [[48]]$hair_color #> [1] "none" #> #> [[48]]$skin_color #> [1] "dark" #> #> [[48]]$eye_color #> [1] "brown" #> #> [[48]]$birth_year #> [1] "72BBY" #> #> [[48]]$gender #> [1] "male" #> #> [[48]]$homeworld #> [1] "http://swapi.co/api/planets/42/" #> #> [[48]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[48]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[48]]$created #> [1] "2014-12-20T10:12:30.846000Z" #> #> [[48]]$edited #> [1] "2014-12-20T21:17:50.420000Z" #> #> [[48]]$url #> [1] "http://swapi.co/api/people/51/" #> #> #> [[49]] #> [[49]]$name #> [1] "Ki-Adi-Mundi" #> #> [[49]]$height #> [1] "198" #> #> [[49]]$mass #> [1] "82" #> #> [[49]]$hair_color #> [1] "white" #> #> [[49]]$skin_color #> [1] "pale" #> #> [[49]]$eye_color #> [1] "yellow" #> #> [[49]]$birth_year #> [1] "92BBY" #> #> [[49]]$gender #> [1] "male" #> #> [[49]]$homeworld #> [1] "http://swapi.co/api/planets/43/" #> #> [[49]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[49]]$species #> [1] "http://swapi.co/api/species/20/" #> #> [[49]]$created #> [1] "2014-12-20T10:15:32.293000Z" #> #> [[49]]$edited #> [1] "2014-12-20T21:17:50.422000Z" #> #> [[49]]$url #> [1] "http://swapi.co/api/people/52/" #> #> #> [[50]] #> [[50]]$name #> [1] "Kit Fisto" #> #> [[50]]$height #> [1] "196" #> #> [[50]]$mass #> [1] "87" #> #> [[50]]$hair_color #> [1] "none" #> #> [[50]]$skin_color #> [1] "green" #> #> [[50]]$eye_color #> [1] "black" #> #> [[50]]$birth_year #> [1] "unknown" #> #> [[50]]$gender #> [1] "male" #> #> [[50]]$homeworld #> [1] "http://swapi.co/api/planets/44/" #> #> [[50]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[50]]$species #> [1] "http://swapi.co/api/species/21/" #> #> [[50]]$created #> [1] "2014-12-20T10:18:57.202000Z" #> #> [[50]]$edited #> [1] "2014-12-20T21:17:50.424000Z" #> #> [[50]]$url #> [1] "http://swapi.co/api/people/53/" #> #> #> [[51]] #> [[51]]$name #> [1] "Eeth Koth" #> #> [[51]]$height #> [1] "171" #> #> [[51]]$mass #> [1] "unknown" #> #> [[51]]$hair_color #> [1] "black" #> #> [[51]]$skin_color #> [1] "brown" #> #> [[51]]$eye_color #> [1] "brown" #> #> [[51]]$birth_year #> [1] "unknown" #> #> [[51]]$gender #> [1] "male" #> #> [[51]]$homeworld #> [1] "http://swapi.co/api/planets/45/" #> #> [[51]]$films #> [1] "http://swapi.co/api/films/4/" "http://swapi.co/api/films/6/" #> #> [[51]]$species #> [1] "http://swapi.co/api/species/22/" #> #> [[51]]$created #> [1] "2014-12-20T10:26:47.902000Z" #> #> [[51]]$edited #> [1] "2014-12-20T21:17:50.427000Z" #> #> [[51]]$url #> [1] "http://swapi.co/api/people/54/" #> #> #> [[52]] #> [[52]]$name #> [1] "Adi Gallia" #> #> [[52]]$height #> [1] "184" #> #> [[52]]$mass #> [1] "50" #> #> [[52]]$hair_color #> [1] "none" #> #> [[52]]$skin_color #> [1] "dark" #> #> [[52]]$eye_color #> [1] "blue" #> #> [[52]]$birth_year #> [1] "unknown" #> #> [[52]]$gender #> [1] "female" #> #> [[52]]$homeworld #> [1] "http://swapi.co/api/planets/9/" #> #> [[52]]$films #> [1] "http://swapi.co/api/films/4/" "http://swapi.co/api/films/6/" #> #> [[52]]$species #> [1] "http://swapi.co/api/species/23/" #> #> [[52]]$created #> [1] "2014-12-20T10:29:11.661000Z" #> #> [[52]]$edited #> [1] "2014-12-20T21:17:50.432000Z" #> #> [[52]]$url #> [1] "http://swapi.co/api/people/55/" #> #> #> [[53]] #> [[53]]$name #> [1] "Saesee Tiin" #> #> [[53]]$height #> [1] "188" #> #> [[53]]$mass #> [1] "unknown" #> #> [[53]]$hair_color #> [1] "none" #> #> [[53]]$skin_color #> [1] "pale" #> #> [[53]]$eye_color #> [1] "orange" #> #> [[53]]$birth_year #> [1] "unknown" #> #> [[53]]$gender #> [1] "male" #> #> [[53]]$homeworld #> [1] "http://swapi.co/api/planets/47/" #> #> [[53]]$films #> [1] "http://swapi.co/api/films/4/" "http://swapi.co/api/films/6/" #> #> [[53]]$species #> [1] "http://swapi.co/api/species/24/" #> #> [[53]]$created #> [1] "2014-12-20T10:32:11.669000Z" #> #> [[53]]$edited #> [1] "2014-12-20T21:17:50.434000Z" #> #> [[53]]$url #> [1] "http://swapi.co/api/people/56/" #> #> #> [[54]] #> [[54]]$name #> [1] "Yarael Poof" #> #> [[54]]$height #> [1] "264" #> #> [[54]]$mass #> [1] "unknown" #> #> [[54]]$hair_color #> [1] "none" #> #> [[54]]$skin_color #> [1] "white" #> #> [[54]]$eye_color #> [1] "yellow" #> #> [[54]]$birth_year #> [1] "unknown" #> #> [[54]]$gender #> [1] "male" #> #> [[54]]$homeworld #> [1] "http://swapi.co/api/planets/48/" #> #> [[54]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[54]]$species #> [1] "http://swapi.co/api/species/25/" #> #> [[54]]$created #> [1] "2014-12-20T10:34:48.725000Z" #> #> [[54]]$edited #> [1] "2014-12-20T21:17:50.437000Z" #> #> [[54]]$url #> [1] "http://swapi.co/api/people/57/" #> #> #> [[55]] #> [[55]]$name #> [1] "Plo Koon" #> #> [[55]]$height #> [1] "188" #> #> [[55]]$mass #> [1] "80" #> #> [[55]]$hair_color #> [1] "none" #> #> [[55]]$skin_color #> [1] "orange" #> #> [[55]]$eye_color #> [1] "black" #> #> [[55]]$birth_year #> [1] "22BBY" #> #> [[55]]$gender #> [1] "male" #> #> [[55]]$homeworld #> [1] "http://swapi.co/api/planets/49/" #> #> [[55]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[55]]$species #> [1] "http://swapi.co/api/species/26/" #> #> [[55]]$starships #> [1] "http://swapi.co/api/starships/48/" #> #> [[55]]$created #> [1] "2014-12-20T10:49:19.859000Z" #> #> [[55]]$edited #> [1] "2014-12-20T21:17:50.439000Z" #> #> [[55]]$url #> [1] "http://swapi.co/api/people/58/" #> #> #> [[56]] #> [[56]]$name #> [1] "Mas Amedda" #> #> [[56]]$height #> [1] "196" #> #> [[56]]$mass #> [1] "unknown" #> #> [[56]]$hair_color #> [1] "none" #> #> [[56]]$skin_color #> [1] "blue" #> #> [[56]]$eye_color #> [1] "blue" #> #> [[56]]$birth_year #> [1] "unknown" #> #> [[56]]$gender #> [1] "male" #> #> [[56]]$homeworld #> [1] "http://swapi.co/api/planets/50/" #> #> [[56]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> #> [[56]]$species #> [1] "http://swapi.co/api/species/27/" #> #> [[56]]$created #> [1] "2014-12-20T10:53:26.457000Z" #> #> [[56]]$edited #> [1] "2014-12-20T21:17:50.442000Z" #> #> [[56]]$url #> [1] "http://swapi.co/api/people/59/" #> #> #> [[57]] #> [[57]]$name #> [1] "Gregar Typho" #> #> [[57]]$height #> [1] "185" #> #> [[57]]$mass #> [1] "85" #> #> [[57]]$hair_color #> [1] "black" #> #> [[57]]$skin_color #> [1] "dark" #> #> [[57]]$eye_color #> [1] "brown" #> #> [[57]]$birth_year #> [1] "unknown" #> #> [[57]]$gender #> [1] "male" #> #> [[57]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[57]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[57]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[57]]$starships #> [1] "http://swapi.co/api/starships/39/" #> #> [[57]]$created #> [1] "2014-12-20T11:10:10.381000Z" #> #> [[57]]$edited #> [1] "2014-12-20T21:17:50.445000Z" #> #> [[57]]$url #> [1] "http://swapi.co/api/people/60/" #> #> #> [[58]] #> [[58]]$name #> [1] "Cordé" #> #> [[58]]$height #> [1] "157" #> #> [[58]]$mass #> [1] "unknown" #> #> [[58]]$hair_color #> [1] "brown" #> #> [[58]]$skin_color #> [1] "light" #> #> [[58]]$eye_color #> [1] "brown" #> #> [[58]]$birth_year #> [1] "unknown" #> #> [[58]]$gender #> [1] "female" #> #> [[58]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[58]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[58]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[58]]$created #> [1] "2014-12-20T11:11:39.630000Z" #> #> [[58]]$edited #> [1] "2014-12-20T21:17:50.449000Z" #> #> [[58]]$url #> [1] "http://swapi.co/api/people/61/" #> #> #> [[59]] #> [[59]]$name #> [1] "Cliegg Lars" #> #> [[59]]$height #> [1] "183" #> #> [[59]]$mass #> [1] "unknown" #> #> [[59]]$hair_color #> [1] "brown" #> #> [[59]]$skin_color #> [1] "fair" #> #> [[59]]$eye_color #> [1] "blue" #> #> [[59]]$birth_year #> [1] "82BBY" #> #> [[59]]$gender #> [1] "male" #> #> [[59]]$homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> [[59]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[59]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[59]]$created #> [1] "2014-12-20T15:59:03.958000Z" #> #> [[59]]$edited #> [1] "2014-12-20T21:17:50.451000Z" #> #> [[59]]$url #> [1] "http://swapi.co/api/people/62/" #> #> #> [[60]] #> [[60]]$name #> [1] "Poggle the Lesser" #> #> [[60]]$height #> [1] "183" #> #> [[60]]$mass #> [1] "80" #> #> [[60]]$hair_color #> [1] "none" #> #> [[60]]$skin_color #> [1] "green" #> #> [[60]]$eye_color #> [1] "yellow" #> #> [[60]]$birth_year #> [1] "unknown" #> #> [[60]]$gender #> [1] "male" #> #> [[60]]$homeworld #> [1] "http://swapi.co/api/planets/11/" #> #> [[60]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[60]]$species #> [1] "http://swapi.co/api/species/28/" #> #> [[60]]$created #> [1] "2014-12-20T16:40:43.977000Z" #> #> [[60]]$edited #> [1] "2014-12-20T21:17:50.453000Z" #> #> [[60]]$url #> [1] "http://swapi.co/api/people/63/" #> #> #> [[61]] #> [[61]]$name #> [1] "Luminara Unduli" #> #> [[61]]$height #> [1] "170" #> #> [[61]]$mass #> [1] "56.2" #> #> [[61]]$hair_color #> [1] "black" #> #> [[61]]$skin_color #> [1] "yellow" #> #> [[61]]$eye_color #> [1] "blue" #> #> [[61]]$birth_year #> [1] "58BBY" #> #> [[61]]$gender #> [1] "female" #> #> [[61]]$homeworld #> [1] "http://swapi.co/api/planets/51/" #> #> [[61]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[61]]$species #> [1] "http://swapi.co/api/species/29/" #> #> [[61]]$created #> [1] "2014-12-20T16:45:53.668000Z" #> #> [[61]]$edited #> [1] "2014-12-20T21:17:50.455000Z" #> #> [[61]]$url #> [1] "http://swapi.co/api/people/64/" #> #> #> [[62]] #> [[62]]$name #> [1] "Barriss Offee" #> #> [[62]]$height #> [1] "166" #> #> [[62]]$mass #> [1] "50" #> #> [[62]]$hair_color #> [1] "black" #> #> [[62]]$skin_color #> [1] "yellow" #> #> [[62]]$eye_color #> [1] "blue" #> #> [[62]]$birth_year #> [1] "40BBY" #> #> [[62]]$gender #> [1] "female" #> #> [[62]]$homeworld #> [1] "http://swapi.co/api/planets/51/" #> #> [[62]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[62]]$species #> [1] "http://swapi.co/api/species/29/" #> #> [[62]]$created #> [1] "2014-12-20T16:46:40.440000Z" #> #> [[62]]$edited #> [1] "2014-12-20T21:17:50.457000Z" #> #> [[62]]$url #> [1] "http://swapi.co/api/people/65/" #> #> #> [[63]] #> [[63]]$name #> [1] "Dormé" #> #> [[63]]$height #> [1] "165" #> #> [[63]]$mass #> [1] "unknown" #> #> [[63]]$hair_color #> [1] "brown" #> #> [[63]]$skin_color #> [1] "light" #> #> [[63]]$eye_color #> [1] "brown" #> #> [[63]]$birth_year #> [1] "unknown" #> #> [[63]]$gender #> [1] "female" #> #> [[63]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[63]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[63]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[63]]$created #> [1] "2014-12-20T16:49:14.640000Z" #> #> [[63]]$edited #> [1] "2014-12-20T21:17:50.460000Z" #> #> [[63]]$url #> [1] "http://swapi.co/api/people/66/" #> #> #> [[64]] #> [[64]]$name #> [1] "Dooku" #> #> [[64]]$height #> [1] "193" #> #> [[64]]$mass #> [1] "80" #> #> [[64]]$hair_color #> [1] "white" #> #> [[64]]$skin_color #> [1] "fair" #> #> [[64]]$eye_color #> [1] "brown" #> #> [[64]]$birth_year #> [1] "102BBY" #> #> [[64]]$gender #> [1] "male" #> #> [[64]]$homeworld #> [1] "http://swapi.co/api/planets/52/" #> #> [[64]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[64]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[64]]$vehicles #> [1] "http://swapi.co/api/vehicles/55/" #> #> [[64]]$created #> [1] "2014-12-20T16:52:14.726000Z" #> #> [[64]]$edited #> [1] "2014-12-20T21:17:50.462000Z" #> #> [[64]]$url #> [1] "http://swapi.co/api/people/67/" #> #> #> [[65]] #> [[65]]$name #> [1] "Bail Prestor Organa" #> #> [[65]]$height #> [1] "191" #> #> [[65]]$mass #> [1] "unknown" #> #> [[65]]$hair_color #> [1] "black" #> #> [[65]]$skin_color #> [1] "tan" #> #> [[65]]$eye_color #> [1] "brown" #> #> [[65]]$birth_year #> [1] "67BBY" #> #> [[65]]$gender #> [1] "male" #> #> [[65]]$homeworld #> [1] "http://swapi.co/api/planets/2/" #> #> [[65]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[65]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[65]]$created #> [1] "2014-12-20T16:53:08.575000Z" #> #> [[65]]$edited #> [1] "2014-12-20T21:17:50.463000Z" #> #> [[65]]$url #> [1] "http://swapi.co/api/people/68/" #> #> #> [[66]] #> [[66]]$name #> [1] "Jango Fett" #> #> [[66]]$height #> [1] "183" #> #> [[66]]$mass #> [1] "79" #> #> [[66]]$hair_color #> [1] "black" #> #> [[66]]$skin_color #> [1] "tan" #> #> [[66]]$eye_color #> [1] "brown" #> #> [[66]]$birth_year #> [1] "66BBY" #> #> [[66]]$gender #> [1] "male" #> #> [[66]]$homeworld #> [1] "http://swapi.co/api/planets/53/" #> #> [[66]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[66]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[66]]$created #> [1] "2014-12-20T16:54:41.620000Z" #> #> [[66]]$edited #> [1] "2014-12-20T21:17:50.465000Z" #> #> [[66]]$url #> [1] "http://swapi.co/api/people/69/" #> #> #> [[67]] #> [[67]]$name #> [1] "Zam Wesell" #> #> [[67]]$height #> [1] "168" #> #> [[67]]$mass #> [1] "55" #> #> [[67]]$hair_color #> [1] "blonde" #> #> [[67]]$skin_color #> [1] "fair, green, yellow" #> #> [[67]]$eye_color #> [1] "yellow" #> #> [[67]]$birth_year #> [1] "unknown" #> #> [[67]]$gender #> [1] "female" #> #> [[67]]$homeworld #> [1] "http://swapi.co/api/planets/54/" #> #> [[67]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[67]]$species #> [1] "http://swapi.co/api/species/30/" #> #> [[67]]$vehicles #> [1] "http://swapi.co/api/vehicles/45/" #> #> [[67]]$created #> [1] "2014-12-20T16:57:44.471000Z" #> #> [[67]]$edited #> [1] "2014-12-20T21:17:50.468000Z" #> #> [[67]]$url #> [1] "http://swapi.co/api/people/70/" #> #> #> [[68]] #> [[68]]$name #> [1] "Dexter Jettster" #> #> [[68]]$height #> [1] "198" #> #> [[68]]$mass #> [1] "102" #> #> [[68]]$hair_color #> [1] "none" #> #> [[68]]$skin_color #> [1] "brown" #> #> [[68]]$eye_color #> [1] "yellow" #> #> [[68]]$birth_year #> [1] "unknown" #> #> [[68]]$gender #> [1] "male" #> #> [[68]]$homeworld #> [1] "http://swapi.co/api/planets/55/" #> #> [[68]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[68]]$species #> [1] "http://swapi.co/api/species/31/" #> #> [[68]]$created #> [1] "2014-12-20T17:28:27.248000Z" #> #> [[68]]$edited #> [1] "2014-12-20T21:17:50.470000Z" #> #> [[68]]$url #> [1] "http://swapi.co/api/people/71/" #> #> #> [[69]] #> [[69]]$name #> [1] "Lama Su" #> #> [[69]]$height #> [1] "229" #> #> [[69]]$mass #> [1] "88" #> #> [[69]]$hair_color #> [1] "none" #> #> [[69]]$skin_color #> [1] "grey" #> #> [[69]]$eye_color #> [1] "black" #> #> [[69]]$birth_year #> [1] "unknown" #> #> [[69]]$gender #> [1] "male" #> #> [[69]]$homeworld #> [1] "http://swapi.co/api/planets/10/" #> #> [[69]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[69]]$species #> [1] "http://swapi.co/api/species/32/" #> #> [[69]]$created #> [1] "2014-12-20T17:30:50.416000Z" #> #> [[69]]$edited #> [1] "2014-12-20T21:17:50.473000Z" #> #> [[69]]$url #> [1] "http://swapi.co/api/people/72/" #> #> #> [[70]] #> [[70]]$name #> [1] "Taun We" #> #> [[70]]$height #> [1] "213" #> #> [[70]]$mass #> [1] "unknown" #> #> [[70]]$hair_color #> [1] "none" #> #> [[70]]$skin_color #> [1] "grey" #> #> [[70]]$eye_color #> [1] "black" #> #> [[70]]$birth_year #> [1] "unknown" #> #> [[70]]$gender #> [1] "female" #> #> [[70]]$homeworld #> [1] "http://swapi.co/api/planets/10/" #> #> [[70]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[70]]$species #> [1] "http://swapi.co/api/species/32/" #> #> [[70]]$created #> [1] "2014-12-20T17:31:21.195000Z" #> #> [[70]]$edited #> [1] "2014-12-20T21:17:50.474000Z" #> #> [[70]]$url #> [1] "http://swapi.co/api/people/73/" #> #> #> [[71]] #> [[71]]$name #> [1] "Jocasta Nu" #> #> [[71]]$height #> [1] "167" #> #> [[71]]$mass #> [1] "unknown" #> #> [[71]]$hair_color #> [1] "white" #> #> [[71]]$skin_color #> [1] "fair" #> #> [[71]]$eye_color #> [1] "blue" #> #> [[71]]$birth_year #> [1] "unknown" #> #> [[71]]$gender #> [1] "female" #> #> [[71]]$homeworld #> [1] "http://swapi.co/api/planets/9/" #> #> [[71]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[71]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[71]]$created #> [1] "2014-12-20T17:32:51.996000Z" #> #> [[71]]$edited #> [1] "2014-12-20T21:17:50.476000Z" #> #> [[71]]$url #> [1] "http://swapi.co/api/people/74/" #> #> #> [[72]] #> [[72]]$name #> [1] "Ratts Tyerell" #> #> [[72]]$height #> [1] "79" #> #> [[72]]$mass #> [1] "15" #> #> [[72]]$hair_color #> [1] "none" #> #> [[72]]$skin_color #> [1] "grey, blue" #> #> [[72]]$eye_color #> [1] "unknown" #> #> [[72]]$birth_year #> [1] "unknown" #> #> [[72]]$gender #> [1] "male" #> #> [[72]]$homeworld #> [1] "http://swapi.co/api/planets/38/" #> #> [[72]]$films #> [1] "http://swapi.co/api/films/4/" #> #> [[72]]$species #> [1] "http://swapi.co/api/species/16/" #> #> [[72]]$created #> [1] "2014-12-20T09:53:15.086000Z" #> #> [[72]]$edited #> [1] "2016-06-30T12:52:19.604868Z" #> #> [[72]]$url #> [1] "http://swapi.co/api/people/47/" #> #> #> [[73]] #> [[73]]$name #> [1] "R4-P17" #> #> [[73]]$height #> [1] "96" #> #> [[73]]$mass #> [1] "unknown" #> #> [[73]]$hair_color #> [1] "none" #> #> [[73]]$skin_color #> [1] "silver, red" #> #> [[73]]$eye_color #> [1] "red, blue" #> #> [[73]]$birth_year #> [1] "unknown" #> #> [[73]]$gender #> [1] "female" #> #> [[73]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[73]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[73]]$created #> [1] "2014-12-20T17:43:36.409000Z" #> #> [[73]]$edited #> [1] "2014-12-20T21:17:50.478000Z" #> #> [[73]]$url #> [1] "http://swapi.co/api/people/75/" #> #> #> [[74]] #> [[74]]$name #> [1] "Wat Tambor" #> #> [[74]]$height #> [1] "193" #> #> [[74]]$mass #> [1] "48" #> #> [[74]]$hair_color #> [1] "none" #> #> [[74]]$skin_color #> [1] "green, grey" #> #> [[74]]$eye_color #> [1] "unknown" #> #> [[74]]$birth_year #> [1] "unknown" #> #> [[74]]$gender #> [1] "male" #> #> [[74]]$homeworld #> [1] "http://swapi.co/api/planets/56/" #> #> [[74]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[74]]$species #> [1] "http://swapi.co/api/species/33/" #> #> [[74]]$created #> [1] "2014-12-20T17:53:52.607000Z" #> #> [[74]]$edited #> [1] "2014-12-20T21:17:50.481000Z" #> #> [[74]]$url #> [1] "http://swapi.co/api/people/76/" #> #> #> [[75]] #> [[75]]$name #> [1] "San Hill" #> #> [[75]]$height #> [1] "191" #> #> [[75]]$mass #> [1] "unknown" #> #> [[75]]$hair_color #> [1] "none" #> #> [[75]]$skin_color #> [1] "grey" #> #> [[75]]$eye_color #> [1] "gold" #> #> [[75]]$birth_year #> [1] "unknown" #> #> [[75]]$gender #> [1] "male" #> #> [[75]]$homeworld #> [1] "http://swapi.co/api/planets/57/" #> #> [[75]]$films #> [1] "http://swapi.co/api/films/5/" #> #> [[75]]$species #> [1] "http://swapi.co/api/species/34/" #> #> [[75]]$created #> [1] "2014-12-20T17:58:17.049000Z" #> #> [[75]]$edited #> [1] "2014-12-20T21:17:50.484000Z" #> #> [[75]]$url #> [1] "http://swapi.co/api/people/77/" #> #> #> [[76]] #> [[76]]$name #> [1] "Shaak Ti" #> #> [[76]]$height #> [1] "178" #> #> [[76]]$mass #> [1] "57" #> #> [[76]]$hair_color #> [1] "none" #> #> [[76]]$skin_color #> [1] "red, blue, white" #> #> [[76]]$eye_color #> [1] "black" #> #> [[76]]$birth_year #> [1] "unknown" #> #> [[76]]$gender #> [1] "female" #> #> [[76]]$homeworld #> [1] "http://swapi.co/api/planets/58/" #> #> [[76]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[76]]$species #> [1] "http://swapi.co/api/species/35/" #> #> [[76]]$created #> [1] "2014-12-20T18:44:01.103000Z" #> #> [[76]]$edited #> [1] "2014-12-20T21:17:50.486000Z" #> #> [[76]]$url #> [1] "http://swapi.co/api/people/78/" #> #> #> [[77]] #> [[77]]$name #> [1] "Grievous" #> #> [[77]]$height #> [1] "216" #> #> [[77]]$mass #> [1] "159" #> #> [[77]]$hair_color #> [1] "none" #> #> [[77]]$skin_color #> [1] "brown, white" #> #> [[77]]$eye_color #> [1] "green, yellow" #> #> [[77]]$birth_year #> [1] "unknown" #> #> [[77]]$gender #> [1] "male" #> #> [[77]]$homeworld #> [1] "http://swapi.co/api/planets/59/" #> #> [[77]]$films #> [1] "http://swapi.co/api/films/6/" #> #> [[77]]$species #> [1] "http://swapi.co/api/species/36/" #> #> [[77]]$vehicles #> [1] "http://swapi.co/api/vehicles/60/" #> #> [[77]]$starships #> [1] "http://swapi.co/api/starships/74/" #> #> [[77]]$created #> [1] "2014-12-20T19:43:53.348000Z" #> #> [[77]]$edited #> [1] "2014-12-20T21:17:50.488000Z" #> #> [[77]]$url #> [1] "http://swapi.co/api/people/79/" #> #> #> [[78]] #> [[78]]$name #> [1] "Tarfful" #> #> [[78]]$height #> [1] "234" #> #> [[78]]$mass #> [1] "136" #> #> [[78]]$hair_color #> [1] "brown" #> #> [[78]]$skin_color #> [1] "brown" #> #> [[78]]$eye_color #> [1] "blue" #> #> [[78]]$birth_year #> [1] "unknown" #> #> [[78]]$gender #> [1] "male" #> #> [[78]]$homeworld #> [1] "http://swapi.co/api/planets/14/" #> #> [[78]]$films #> [1] "http://swapi.co/api/films/6/" #> #> [[78]]$species #> [1] "http://swapi.co/api/species/3/" #> #> [[78]]$created #> [1] "2014-12-20T19:46:34.209000Z" #> #> [[78]]$edited #> [1] "2014-12-20T21:17:50.491000Z" #> #> [[78]]$url #> [1] "http://swapi.co/api/people/80/" #> #> #> [[79]] #> [[79]]$name #> [1] "Raymus Antilles" #> #> [[79]]$height #> [1] "188" #> #> [[79]]$mass #> [1] "79" #> #> [[79]]$hair_color #> [1] "brown" #> #> [[79]]$skin_color #> [1] "light" #> #> [[79]]$eye_color #> [1] "brown" #> #> [[79]]$birth_year #> [1] "unknown" #> #> [[79]]$gender #> [1] "male" #> #> [[79]]$homeworld #> [1] "http://swapi.co/api/planets/2/" #> #> [[79]]$films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/1/" #> #> [[79]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[79]]$created #> [1] "2014-12-20T19:49:35.583000Z" #> #> [[79]]$edited #> [1] "2014-12-20T21:17:50.493000Z" #> #> [[79]]$url #> [1] "http://swapi.co/api/people/81/" #> #> #> [[80]] #> [[80]]$name #> [1] "Sly Moore" #> #> [[80]]$height #> [1] "178" #> #> [[80]]$mass #> [1] "48" #> #> [[80]]$hair_color #> [1] "none" #> #> [[80]]$skin_color #> [1] "pale" #> #> [[80]]$eye_color #> [1] "white" #> #> [[80]]$birth_year #> [1] "unknown" #> #> [[80]]$gender #> [1] "female" #> #> [[80]]$homeworld #> [1] "http://swapi.co/api/planets/60/" #> #> [[80]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/6/" #> #> [[80]]$created #> [1] "2014-12-20T20:18:37.619000Z" #> #> [[80]]$edited #> [1] "2014-12-20T21:17:50.496000Z" #> #> [[80]]$url #> [1] "http://swapi.co/api/people/82/" #> #> #> [[81]] #> [[81]]$name #> [1] "Tion Medon" #> #> [[81]]$height #> [1] "206" #> #> [[81]]$mass #> [1] "80" #> #> [[81]]$hair_color #> [1] "none" #> #> [[81]]$skin_color #> [1] "grey" #> #> [[81]]$eye_color #> [1] "black" #> #> [[81]]$birth_year #> [1] "unknown" #> #> [[81]]$gender #> [1] "male" #> #> [[81]]$homeworld #> [1] "http://swapi.co/api/planets/12/" #> #> [[81]]$films #> [1] "http://swapi.co/api/films/6/" #> #> [[81]]$species #> [1] "http://swapi.co/api/species/37/" #> #> [[81]]$created #> [1] "2014-12-20T20:35:04.260000Z" #> #> [[81]]$edited #> [1] "2014-12-20T21:17:50.498000Z" #> #> [[81]]$url #> [1] "http://swapi.co/api/people/83/" #> #> #> [[82]] #> [[82]]$name #> [1] "Finn" #> #> [[82]]$height #> [1] "unknown" #> #> [[82]]$mass #> [1] "unknown" #> #> [[82]]$hair_color #> [1] "black" #> #> [[82]]$skin_color #> [1] "dark" #> #> [[82]]$eye_color #> [1] "dark" #> #> [[82]]$birth_year #> [1] "unknown" #> #> [[82]]$gender #> [1] "male" #> #> [[82]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[82]]$films #> [1] "http://swapi.co/api/films/7/" #> #> [[82]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[82]]$created #> [1] "2015-04-17T06:52:40.793621Z" #> #> [[82]]$edited #> [1] "2015-04-17T06:52:40.793674Z" #> #> [[82]]$url #> [1] "http://swapi.co/api/people/84/" #> #> #> [[83]] #> [[83]]$name #> [1] "Rey" #> #> [[83]]$height #> [1] "unknown" #> #> [[83]]$mass #> [1] "unknown" #> #> [[83]]$hair_color #> [1] "brown" #> #> [[83]]$skin_color #> [1] "light" #> #> [[83]]$eye_color #> [1] "hazel" #> #> [[83]]$birth_year #> [1] "unknown" #> #> [[83]]$gender #> [1] "female" #> #> [[83]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[83]]$films #> [1] "http://swapi.co/api/films/7/" #> #> [[83]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[83]]$created #> [1] "2015-04-17T06:54:01.495077Z" #> #> [[83]]$edited #> [1] "2015-04-17T06:54:01.495128Z" #> #> [[83]]$url #> [1] "http://swapi.co/api/people/85/" #> #> #> [[84]] #> [[84]]$name #> [1] "Poe Dameron" #> #> [[84]]$height #> [1] "unknown" #> #> [[84]]$mass #> [1] "unknown" #> #> [[84]]$hair_color #> [1] "brown" #> #> [[84]]$skin_color #> [1] "light" #> #> [[84]]$eye_color #> [1] "brown" #> #> [[84]]$birth_year #> [1] "unknown" #> #> [[84]]$gender #> [1] "male" #> #> [[84]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[84]]$films #> [1] "http://swapi.co/api/films/7/" #> #> [[84]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[84]]$starships #> [1] "http://swapi.co/api/starships/77/" #> #> [[84]]$created #> [1] "2015-04-17T06:55:21.622786Z" #> #> [[84]]$edited #> [1] "2015-04-17T06:55:21.622835Z" #> #> [[84]]$url #> [1] "http://swapi.co/api/people/86/" #> #> #> [[85]] #> [[85]]$name #> [1] "BB8" #> #> [[85]]$height #> [1] "unknown" #> #> [[85]]$mass #> [1] "unknown" #> #> [[85]]$hair_color #> [1] "none" #> #> [[85]]$skin_color #> [1] "none" #> #> [[85]]$eye_color #> [1] "black" #> #> [[85]]$birth_year #> [1] "unknown" #> #> [[85]]$gender #> [1] "none" #> #> [[85]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[85]]$films #> [1] "http://swapi.co/api/films/7/" #> #> [[85]]$species #> [1] "http://swapi.co/api/species/2/" #> #> [[85]]$created #> [1] "2015-04-17T06:57:38.061346Z" #> #> [[85]]$edited #> [1] "2015-04-17T06:57:38.061453Z" #> #> [[85]]$url #> [1] "http://swapi.co/api/people/87/" #> #> #> [[86]] #> [[86]]$name #> [1] "Captain Phasma" #> #> [[86]]$height #> [1] "unknown" #> #> [[86]]$mass #> [1] "unknown" #> #> [[86]]$hair_color #> [1] "unknown" #> #> [[86]]$skin_color #> [1] "unknown" #> #> [[86]]$eye_color #> [1] "unknown" #> #> [[86]]$birth_year #> [1] "unknown" #> #> [[86]]$gender #> [1] "female" #> #> [[86]]$homeworld #> [1] "http://swapi.co/api/planets/28/" #> #> [[86]]$films #> [1] "http://swapi.co/api/films/7/" #> #> [[86]]$created #> [1] "2015-10-13T10:35:39.229823Z" #> #> [[86]]$edited #> [1] "2015-10-13T10:35:39.229894Z" #> #> [[86]]$url #> [1] "http://swapi.co/api/people/88/" #> #> #> [[87]] #> [[87]]$name #> [1] "Padmé Amidala" #> #> [[87]]$height #> [1] "165" #> #> [[87]]$mass #> [1] "45" #> #> [[87]]$hair_color #> [1] "brown" #> #> [[87]]$skin_color #> [1] "light" #> #> [[87]]$eye_color #> [1] "brown" #> #> [[87]]$birth_year #> [1] "46BBY" #> #> [[87]]$gender #> [1] "female" #> #> [[87]]$homeworld #> [1] "http://swapi.co/api/planets/8/" #> #> [[87]]$films #> [1] "http://swapi.co/api/films/5/" "http://swapi.co/api/films/4/" #> [3] "http://swapi.co/api/films/6/" #> #> [[87]]$species #> [1] "http://swapi.co/api/species/1/" #> #> [[87]]$starships #> [1] "http://swapi.co/api/starships/49/" "http://swapi.co/api/starships/64/" #> [3] "http://swapi.co/api/starships/39/" #> #> [[87]]$created #> [1] "2014-12-19T17:28:26.926000Z" #> #> [[87]]$edited #> [1] "2016-04-20T17:06:31.502555Z" #> #> [[87]]$url #> [1] "http://swapi.co/api/people/35/" ``` ] .rightcol[ <center> <img src="images/logo_star-wars.png" width=500> </center> ] --- ## How many films was each Star Wars character in? ## `map(sw_people, f = 🤷)` -- #### Workflow: ### 1. Do it for one element. ### 2. Find the general recipe. ### 3. Drop into `map()` to do for all. --- # 1. Do it for one element -- .leftcol[ ```r x <- sw_people[[1]] x ``` ``` #> $name #> [1] "Luke Skywalker" #> #> $height #> [1] "172" #> #> $mass #> [1] "77" #> #> $hair_color #> [1] "blond" #> #> $skin_color #> [1] "fair" #> #> $eye_color #> [1] "blue" #> #> $birth_year #> [1] "19BBY" #> #> $gender #> [1] "male" #> #> $homeworld #> [1] "http://swapi.co/api/planets/1/" #> #> $films #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> [5] "http://swapi.co/api/films/7/" #> #> $species #> [1] "http://swapi.co/api/species/1/" #> #> $vehicles #> [1] "http://swapi.co/api/vehicles/14/" "http://swapi.co/api/vehicles/30/" #> #> $starships #> [1] "http://swapi.co/api/starships/12/" "http://swapi.co/api/starships/22/" #> #> $created #> [1] "2014-12-09T13:50:51.644000Z" #> #> $edited #> [1] "2014-12-20T21:17:56.891000Z" #> #> $url #> [1] "http://swapi.co/api/people/1/" ``` ] -- .rightcol[ View the variables we have to work with: ```r names(x) ``` ``` #> [1] "name" "height" "mass" "hair_color" "skin_color" #> [6] "eye_color" "birth_year" "gender" "homeworld" "films" #> [11] "species" "vehicles" "starships" "created" "edited" #> [16] "url" ``` Extract the films ```r x$films ``` ``` #> [1] "http://swapi.co/api/films/6/" "http://swapi.co/api/films/3/" #> [3] "http://swapi.co/api/films/2/" "http://swapi.co/api/films/1/" #> [5] "http://swapi.co/api/films/7/" ``` ] --- # 1. Do it for one element ### How many films was each Star Wars character in? -- .leftcol[ Character 1: ```r x <- sw_people[[1]] length(x$films) ``` ``` #> [1] 5 ``` ] -- .rightcol[ Character 2: ```r x <- sw_people[[2]] length(x$films) ``` ``` #> [1] 6 ``` ] --- # 2. Find the general recipe ### How many films was each Star Wars character in? ```r x <- sw_people[[1]] length(x$films) ``` ``` #> [1] 5 ``` #### Recipe: ### `x <- sw_people[[index]]` ### `length(x$films)` --- # 3. Drop into `map()` to do for all items in list. .leftcol[ #### Recipe: ### `x <- sw_people[[index]]` ### `length(x$films)` ] .rightcol[ #### Do for all items in list: ```r get_film_length <- function(x) { return(length(x$films)) } map(sw_people, get_film_length) ``` ``` #> [[1]] #> [1] 5 #> #> [[2]] #> [1] 6 #> #> [[3]] #> [1] 7 #> #> [[4]] #> [1] 4 #> #> [[5]] #> [1] 5 #> #> [[6]] #> [1] 3 #> #> [[7]] #> [1] 3 #> #> [[8]] #> [1] 1 #> #> [[9]] #> [1] 1 #> #> [[10]] #> [1] 6 #> #> [[11]] #> [1] 3 #> #> [[12]] #> [1] 2 #> #> [[13]] #> [1] 5 #> #> [[14]] #> [1] 4 #> #> [[15]] #> [1] 1 #> #> [[16]] #> [1] 3 #> #> [[17]] #> [1] 3 #> #> [[18]] #> [1] 1 #> #> [[19]] #> [1] 5 #> #> [[20]] #> [1] 5 #> #> [[21]] #> [1] 3 #> #> [[22]] #> [1] 1 #> #> [[23]] #> [1] 1 #> #> [[24]] #> [1] 2 #> #> [[25]] #> [1] 1 #> #> [[26]] #> [1] 2 #> #> [[27]] #> [1] 1 #> #> [[28]] #> [1] 1 #> #> [[29]] #> [1] 1 #> #> [[30]] #> [1] 1 #> #> [[31]] #> [1] 1 #> #> [[32]] #> [1] 3 #> #> [[33]] #> [1] 1 #> #> [[34]] #> [1] 2 #> #> [[35]] #> [1] 1 #> #> [[36]] #> [1] 1 #> #> [[37]] #> [1] 1 #> #> [[38]] #> [1] 2 #> #> [[39]] #> [1] 1 #> #> [[40]] #> [1] 1 #> #> [[41]] #> [1] 2 #> #> [[42]] #> [1] 1 #> #> [[43]] #> [1] 1 #> #> [[44]] #> [1] 3 #> #> [[45]] #> [1] 1 #> #> [[46]] #> [1] 1 #> #> [[47]] #> [1] 1 #> #> [[48]] #> [1] 3 #> #> [[49]] #> [1] 3 #> #> [[50]] #> [1] 3 #> #> [[51]] #> [1] 2 #> #> [[52]] #> [1] 2 #> #> [[53]] #> [1] 2 #> #> [[54]] #> [1] 1 #> #> [[55]] #> [1] 3 #> #> [[56]] #> [1] 2 #> #> [[57]] #> [1] 1 #> #> [[58]] #> [1] 1 #> #> [[59]] #> [1] 1 #> #> [[60]] #> [1] 2 #> #> [[61]] #> [1] 2 #> #> [[62]] #> [1] 1 #> #> [[63]] #> [1] 1 #> #> [[64]] #> [1] 2 #> #> [[65]] #> [1] 2 #> #> [[66]] #> [1] 1 #> #> [[67]] #> [1] 1 #> #> [[68]] #> [1] 1 #> #> [[69]] #> [1] 1 #> #> [[70]] #> [1] 1 #> #> [[71]] #> [1] 1 #> #> [[72]] #> [1] 1 #> #> [[73]] #> [1] 2 #> #> [[74]] #> [1] 1 #> #> [[75]] #> [1] 1 #> #> [[76]] #> [1] 2 #> #> [[77]] #> [1] 1 #> #> [[78]] #> [1] 1 #> #> [[79]] #> [1] 2 #> #> [[80]] #> [1] 2 #> #> [[81]] #> [1] 1 #> #> [[82]] #> [1] 1 #> #> [[83]] #> [1] 1 #> #> [[84]] #> [1] 1 #> #> [[85]] #> [1] 1 #> #> [[86]] #> [1] 1 #> #> [[87]] #> [1] 3 ``` ] --- ## for every element of `x` do `f` .leftcol[ <center> <img src="images/map.png" width=650> </center> ] .rightcol[ ```r get_film_length <- function(x) { return(length(x$films)) } map(sw_people, get_film_length) ``` ``` #> [[1]] #> [1] 5 #> #> [[2]] #> [1] 6 #> #> [[3]] #> [1] 7 #> #> [[4]] #> [1] 4 #> #> [[5]] #> [1] 5 #> #> [[6]] #> [1] 3 #> #> [[7]] #> [1] 3 #> #> [[8]] #> [1] 1 #> #> [[9]] #> [1] 1 #> #> [[10]] #> [1] 6 #> #> [[11]] #> [1] 3 #> #> [[12]] #> [1] 2 #> #> [[13]] #> [1] 5 #> #> [[14]] #> [1] 4 #> #> [[15]] #> [1] 1 #> #> [[16]] #> [1] 3 #> #> [[17]] #> [1] 3 #> #> [[18]] #> [1] 1 #> #> [[19]] #> [1] 5 #> #> [[20]] #> [1] 5 #> #> [[21]] #> [1] 3 #> #> [[22]] #> [1] 1 #> #> [[23]] #> [1] 1 #> #> [[24]] #> [1] 2 #> #> [[25]] #> [1] 1 #> #> [[26]] #> [1] 2 #> #> [[27]] #> [1] 1 #> #> [[28]] #> [1] 1 #> #> [[29]] #> [1] 1 #> #> [[30]] #> [1] 1 #> #> [[31]] #> [1] 1 #> #> [[32]] #> [1] 3 #> #> [[33]] #> [1] 1 #> #> [[34]] #> [1] 2 #> #> [[35]] #> [1] 1 #> #> [[36]] #> [1] 1 #> #> [[37]] #> [1] 1 #> #> [[38]] #> [1] 2 #> #> [[39]] #> [1] 1 #> #> [[40]] #> [1] 1 #> #> [[41]] #> [1] 2 #> #> [[42]] #> [1] 1 #> #> [[43]] #> [1] 1 #> #> [[44]] #> [1] 3 #> #> [[45]] #> [1] 1 #> #> [[46]] #> [1] 1 #> #> [[47]] #> [1] 1 #> #> [[48]] #> [1] 3 #> #> [[49]] #> [1] 3 #> #> [[50]] #> [1] 3 #> #> [[51]] #> [1] 2 #> #> [[52]] #> [1] 2 #> #> [[53]] #> [1] 2 #> #> [[54]] #> [1] 1 #> #> [[55]] #> [1] 3 #> #> [[56]] #> [1] 2 #> #> [[57]] #> [1] 1 #> #> [[58]] #> [1] 1 #> #> [[59]] #> [1] 1 #> #> [[60]] #> [1] 2 #> #> [[61]] #> [1] 2 #> #> [[62]] #> [1] 1 #> #> [[63]] #> [1] 1 #> #> [[64]] #> [1] 2 #> #> [[65]] #> [1] 2 #> #> [[66]] #> [1] 1 #> #> [[67]] #> [1] 1 #> #> [[68]] #> [1] 1 #> #> [[69]] #> [1] 1 #> #> [[70]] #> [1] 1 #> #> [[71]] #> [1] 1 #> #> [[72]] #> [1] 1 #> #> [[73]] #> [1] 2 #> #> [[74]] #> [1] 1 #> #> [[75]] #> [1] 1 #> #> [[76]] #> [1] 2 #> #> [[77]] #> [1] 1 #> #> [[78]] #> [1] 1 #> #> [[79]] #> [1] 2 #> #> [[80]] #> [1] 2 #> #> [[81]] #> [1] 1 #> #> [[82]] #> [1] 1 #> #> [[83]] #> [1] 1 #> #> [[84]] #> [1] 1 #> #> [[85]] #> [1] 1 #> #> [[86]] #> [1] 1 #> #> [[87]] #> [1] 3 ``` ] --- # Simplify it with "anonymous" functions .leftcol[ Version 1: **Custom function** ```r get_film_length <- function(x) { return(length(x$films)) } map(sw_people, get_film_length) ``` ``` #> [[1]] #> [1] 5 #> #> [[2]] #> [1] 6 #> #> [[3]] #> [1] 7 #> #> [[4]] #> [1] 4 #> #> [[5]] #> [1] 5 #> #> [[6]] #> [1] 3 #> #> [[7]] #> [1] 3 #> #> [[8]] #> [1] 1 #> #> [[9]] #> [1] 1 #> #> [[10]] #> [1] 6 #> #> [[11]] #> [1] 3 #> #> [[12]] #> [1] 2 #> #> [[13]] #> [1] 5 #> #> [[14]] #> [1] 4 #> #> [[15]] #> [1] 1 #> #> [[16]] #> [1] 3 #> #> [[17]] #> [1] 3 #> #> [[18]] #> [1] 1 #> #> [[19]] #> [1] 5 #> #> [[20]] #> [1] 5 #> #> [[21]] #> [1] 3 #> #> [[22]] #> [1] 1 #> #> [[23]] #> [1] 1 #> #> [[24]] #> [1] 2 #> #> [[25]] #> [1] 1 #> #> [[26]] #> [1] 2 #> #> [[27]] #> [1] 1 #> #> [[28]] #> [1] 1 #> #> [[29]] #> [1] 1 #> #> [[30]] #> [1] 1 #> #> [[31]] #> [1] 1 #> #> [[32]] #> [1] 3 #> #> [[33]] #> [1] 1 #> #> [[34]] #> [1] 2 #> #> [[35]] #> [1] 1 #> #> [[36]] #> [1] 1 #> #> [[37]] #> [1] 1 #> #> [[38]] #> [1] 2 #> #> [[39]] #> [1] 1 #> #> [[40]] #> [1] 1 #> #> [[41]] #> [1] 2 #> #> [[42]] #> [1] 1 #> #> [[43]] #> [1] 1 #> #> [[44]] #> [1] 3 #> #> [[45]] #> [1] 1 #> #> [[46]] #> [1] 1 #> #> [[47]] #> [1] 1 #> #> [[48]] #> [1] 3 #> #> [[49]] #> [1] 3 #> #> [[50]] #> [1] 3 #> #> [[51]] #> [1] 2 #> #> [[52]] #> [1] 2 #> #> [[53]] #> [1] 2 #> #> [[54]] #> [1] 1 #> #> [[55]] #> [1] 3 #> #> [[56]] #> [1] 2 #> #> [[57]] #> [1] 1 #> #> [[58]] #> [1] 1 #> #> [[59]] #> [1] 1 #> #> [[60]] #> [1] 2 #> #> [[61]] #> [1] 2 #> #> [[62]] #> [1] 1 #> #> [[63]] #> [1] 1 #> #> [[64]] #> [1] 2 #> #> [[65]] #> [1] 2 #> #> [[66]] #> [1] 1 #> #> [[67]] #> [1] 1 #> #> [[68]] #> [1] 1 #> #> [[69]] #> [1] 1 #> #> [[70]] #> [1] 1 #> #> [[71]] #> [1] 1 #> #> [[72]] #> [1] 1 #> #> [[73]] #> [1] 2 #> #> [[74]] #> [1] 1 #> #> [[75]] #> [1] 1 #> #> [[76]] #> [1] 2 #> #> [[77]] #> [1] 1 #> #> [[78]] #> [1] 1 #> #> [[79]] #> [1] 2 #> #> [[80]] #> [1] 2 #> #> [[81]] #> [1] 1 #> #> [[82]] #> [1] 1 #> #> [[83]] #> [1] 1 #> #> [[84]] #> [1] 1 #> #> [[85]] #> [1] 1 #> #> [[86]] #> [1] 1 #> #> [[87]] #> [1] 3 ``` ] .rightcol[ Version 2: **Anonymous function** ```r map(sw_people, function(x) length(x$films)) ``` ``` #> [[1]] #> [1] 5 #> #> [[2]] #> [1] 6 #> #> [[3]] #> [1] 7 #> #> [[4]] #> [1] 4 #> #> [[5]] #> [1] 5 #> #> [[6]] #> [1] 3 #> #> [[7]] #> [1] 3 #> #> [[8]] #> [1] 1 #> #> [[9]] #> [1] 1 #> #> [[10]] #> [1] 6 #> #> [[11]] #> [1] 3 #> #> [[12]] #> [1] 2 #> #> [[13]] #> [1] 5 #> #> [[14]] #> [1] 4 #> #> [[15]] #> [1] 1 #> #> [[16]] #> [1] 3 #> #> [[17]] #> [1] 3 #> #> [[18]] #> [1] 1 #> #> [[19]] #> [1] 5 #> #> [[20]] #> [1] 5 #> #> [[21]] #> [1] 3 #> #> [[22]] #> [1] 1 #> #> [[23]] #> [1] 1 #> #> [[24]] #> [1] 2 #> #> [[25]] #> [1] 1 #> #> [[26]] #> [1] 2 #> #> [[27]] #> [1] 1 #> #> [[28]] #> [1] 1 #> #> [[29]] #> [1] 1 #> #> [[30]] #> [1] 1 #> #> [[31]] #> [1] 1 #> #> [[32]] #> [1] 3 #> #> [[33]] #> [1] 1 #> #> [[34]] #> [1] 2 #> #> [[35]] #> [1] 1 #> #> [[36]] #> [1] 1 #> #> [[37]] #> [1] 1 #> #> [[38]] #> [1] 2 #> #> [[39]] #> [1] 1 #> #> [[40]] #> [1] 1 #> #> [[41]] #> [1] 2 #> #> [[42]] #> [1] 1 #> #> [[43]] #> [1] 1 #> #> [[44]] #> [1] 3 #> #> [[45]] #> [1] 1 #> #> [[46]] #> [1] 1 #> #> [[47]] #> [1] 1 #> #> [[48]] #> [1] 3 #> #> [[49]] #> [1] 3 #> #> [[50]] #> [1] 3 #> #> [[51]] #> [1] 2 #> #> [[52]] #> [1] 2 #> #> [[53]] #> [1] 2 #> #> [[54]] #> [1] 1 #> #> [[55]] #> [1] 3 #> #> [[56]] #> [1] 2 #> #> [[57]] #> [1] 1 #> #> [[58]] #> [1] 1 #> #> [[59]] #> [1] 1 #> #> [[60]] #> [1] 2 #> #> [[61]] #> [1] 2 #> #> [[62]] #> [1] 1 #> #> [[63]] #> [1] 1 #> #> [[64]] #> [1] 2 #> #> [[65]] #> [1] 2 #> #> [[66]] #> [1] 1 #> #> [[67]] #> [1] 1 #> #> [[68]] #> [1] 1 #> #> [[69]] #> [1] 1 #> #> [[70]] #> [1] 1 #> #> [[71]] #> [1] 1 #> #> [[72]] #> [1] 1 #> #> [[73]] #> [1] 2 #> #> [[74]] #> [1] 1 #> #> [[75]] #> [1] 1 #> #> [[76]] #> [1] 2 #> #> [[77]] #> [1] 1 #> #> [[78]] #> [1] 1 #> #> [[79]] #> [1] 2 #> #> [[80]] #> [1] 2 #> #> [[81]] #> [1] 1 #> #> [[82]] #> [1] 1 #> #> [[83]] #> [1] 1 #> #> [[84]] #> [1] 1 #> #> [[85]] #> [1] 1 #> #> [[86]] #> [1] 1 #> #> [[87]] #> [1] 3 ``` ] --- ## Anonymous functions Three ways of specifying anonymous functions: ```r map(sw_people, function(x) length( x$films)) # supported in base R map(sw_people, \(x) length( x$films)) # supported R > 4.1.0 map(sw_people, ~ length(.x$films)) # supported in purrr ``` ---
03
:
00
# Quick practice - How many `vehicles` does each Star Wars character have? (use `sw_people`) - How many `titles` does each character in Game of Thrones have? (use `got_chars`) --- ## Type specific map variants ```r map_int(sw_people, \(x) length(x$films)) ``` ``` #> [1] 5 6 7 4 5 3 3 1 1 6 3 2 5 4 1 3 3 1 5 5 3 1 1 2 1 2 1 1 1 1 1 3 1 2 1 1 1 2 #> [39] 1 1 2 1 1 3 1 1 1 3 3 3 2 2 2 1 3 2 1 1 1 2 2 1 1 2 2 1 1 1 1 1 1 1 2 1 1 2 #> [77] 1 1 2 2 1 1 1 1 1 1 3 ``` -- `map_lgl()`: Returns a _logical_ vector `map_int()`: Returns a _integer_ vector `map_dbl()`: Returns a _double_ vector `map_chr()`: Returns a _character_ vector ---
03
:
00
# Quick practice #### Replace `map()` with type-specific `map()`. ```r # What's each character's name? map(got_chars, \(x) x$name) map(sw_people, \(x) x$name) # What color is each SW character's hair? map(sw_people, \(x) x$hair_color) # Is the GoT character alive? map(got_chars, \(x) x$alive) # Is the SW character female? map(sw_people, \(x) x$gender == "female") # How heavy is each SW character? map(sw_people, \(x) x$mass) ``` --- ## How many films was each Star Wars character in? .leftcol[ ```r map(sw_people, \(x) length(x$films)) ``` ``` #> [[1]] #> [1] 5 #> #> [[2]] #> [1] 6 #> #> [[3]] #> [1] 7 #> #> [[4]] #> [1] 4 #> #> [[5]] #> [1] 5 #> #> [[6]] #> [1] 3 #> #> [[7]] #> [1] 3 #> #> [[8]] #> [1] 1 #> #> [[9]] #> [1] 1 #> #> [[10]] #> [1] 6 #> #> [[11]] #> [1] 3 #> #> [[12]] #> [1] 2 #> #> [[13]] #> [1] 5 #> #> [[14]] #> [1] 4 #> #> [[15]] #> [1] 1 #> #> [[16]] #> [1] 3 #> #> [[17]] #> [1] 3 #> #> [[18]] #> [1] 1 #> #> [[19]] #> [1] 5 #> #> [[20]] #> [1] 5 #> #> [[21]] #> [1] 3 #> #> [[22]] #> [1] 1 #> #> [[23]] #> [1] 1 #> #> [[24]] #> [1] 2 #> #> [[25]] #> [1] 1 #> #> [[26]] #> [1] 2 #> #> [[27]] #> [1] 1 #> #> [[28]] #> [1] 1 #> #> [[29]] #> [1] 1 #> #> [[30]] #> [1] 1 #> #> [[31]] #> [1] 1 #> #> [[32]] #> [1] 3 #> #> [[33]] #> [1] 1 #> #> [[34]] #> [1] 2 #> #> [[35]] #> [1] 1 #> #> [[36]] #> [1] 1 #> #> [[37]] #> [1] 1 #> #> [[38]] #> [1] 2 #> #> [[39]] #> [1] 1 #> #> [[40]] #> [1] 1 #> #> [[41]] #> [1] 2 #> #> [[42]] #> [1] 1 #> #> [[43]] #> [1] 1 #> #> [[44]] #> [1] 3 #> #> [[45]] #> [1] 1 #> #> [[46]] #> [1] 1 #> #> [[47]] #> [1] 1 #> #> [[48]] #> [1] 3 #> #> [[49]] #> [1] 3 #> #> [[50]] #> [1] 3 #> #> [[51]] #> [1] 2 #> #> [[52]] #> [1] 2 #> #> [[53]] #> [1] 2 #> #> [[54]] #> [1] 1 #> #> [[55]] #> [1] 3 #> #> [[56]] #> [1] 2 #> #> [[57]] #> [1] 1 #> #> [[58]] #> [1] 1 #> #> [[59]] #> [1] 1 #> #> [[60]] #> [1] 2 #> #> [[61]] #> [1] 2 #> #> [[62]] #> [1] 1 #> #> [[63]] #> [1] 1 #> #> [[64]] #> [1] 2 #> #> [[65]] #> [1] 2 #> #> [[66]] #> [1] 1 #> #> [[67]] #> [1] 1 #> #> [[68]] #> [1] 1 #> #> [[69]] #> [1] 1 #> #> [[70]] #> [1] 1 #> #> [[71]] #> [1] 1 #> #> [[72]] #> [1] 1 #> #> [[73]] #> [1] 2 #> #> [[74]] #> [1] 1 #> #> [[75]] #> [1] 1 #> #> [[76]] #> [1] 2 #> #> [[77]] #> [1] 1 #> #> [[78]] #> [1] 1 #> #> [[79]] #> [1] 2 #> #> [[80]] #> [1] 2 #> #> [[81]] #> [1] 1 #> #> [[82]] #> [1] 1 #> #> [[83]] #> [1] 1 #> #> [[84]] #> [1] 1 #> #> [[85]] #> [1] 1 #> #> [[86]] #> [1] 1 #> #> [[87]] #> [1] 3 ``` ] .rightcol[ <br><br> ### .center[.red[Wait, which character?]] ] --- # Use a tibble to get the character name as well! .leftcol[ Returns a list of data frames: ```r map(sw_people, \(x) tibble( name = x$name, n_vehicles = length(x$films) ) ) ``` ``` #> [[1]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Luke Skywalker 5 #> #> [[2]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 C-3PO 6 #> #> [[3]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 R2-D2 7 #> #> [[4]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Darth Vader 4 #> #> [[5]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Leia Organa 5 #> #> [[6]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Owen Lars 3 #> #> [[7]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Beru Whitesun lars 3 #> #> [[8]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 R5-D4 1 #> #> [[9]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Biggs Darklighter 1 #> #> [[10]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Obi-Wan Kenobi 6 #> #> [[11]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Anakin Skywalker 3 #> #> [[12]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Wilhuff Tarkin 2 #> #> [[13]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Chewbacca 5 #> #> [[14]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Han Solo 4 #> #> [[15]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Greedo 1 #> #> [[16]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Jabba Desilijic Tiure 3 #> #> [[17]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Wedge Antilles 3 #> #> [[18]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Jek Tono Porkins 1 #> #> [[19]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Yoda 5 #> #> [[20]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Palpatine 5 #> #> [[21]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Boba Fett 3 #> #> [[22]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 IG-88 1 #> #> [[23]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Bossk 1 #> #> [[24]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Lando Calrissian 2 #> #> [[25]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Lobot 1 #> #> [[26]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Ackbar 2 #> #> [[27]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Mon Mothma 1 #> #> [[28]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Arvel Crynyd 1 #> #> [[29]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Wicket Systri Warrick 1 #> #> [[30]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Nien Nunb 1 #> #> [[31]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Qui-Gon Jinn 1 #> #> [[32]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Nute Gunray 3 #> #> [[33]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Finis Valorum 1 #> #> [[34]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Jar Jar Binks 2 #> #> [[35]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Roos Tarpals 1 #> #> [[36]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Rugor Nass 1 #> #> [[37]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Ric Olié 1 #> #> [[38]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Watto 2 #> #> [[39]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Sebulba 1 #> #> [[40]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Quarsh Panaka 1 #> #> [[41]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Shmi Skywalker 2 #> #> [[42]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Darth Maul 1 #> #> [[43]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Bib Fortuna 1 #> #> [[44]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Ayla Secura 3 #> #> [[45]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Dud Bolt 1 #> #> [[46]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Gasgano 1 #> #> [[47]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Ben Quadinaros 1 #> #> [[48]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Mace Windu 3 #> #> [[49]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Ki-Adi-Mundi 3 #> #> [[50]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Kit Fisto 3 #> #> [[51]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Eeth Koth 2 #> #> [[52]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Adi Gallia 2 #> #> [[53]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Saesee Tiin 2 #> #> [[54]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Yarael Poof 1 #> #> [[55]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Plo Koon 3 #> #> [[56]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Mas Amedda 2 #> #> [[57]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Gregar Typho 1 #> #> [[58]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Cordé 1 #> #> [[59]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Cliegg Lars 1 #> #> [[60]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Poggle the Lesser 2 #> #> [[61]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Luminara Unduli 2 #> #> [[62]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Barriss Offee 1 #> #> [[63]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Dormé 1 #> #> [[64]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Dooku 2 #> #> [[65]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Bail Prestor Organa 2 #> #> [[66]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Jango Fett 1 #> #> [[67]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Zam Wesell 1 #> #> [[68]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Dexter Jettster 1 #> #> [[69]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Lama Su 1 #> #> [[70]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Taun We 1 #> #> [[71]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Jocasta Nu 1 #> #> [[72]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Ratts Tyerell 1 #> #> [[73]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 R4-P17 2 #> #> [[74]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Wat Tambor 1 #> #> [[75]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 San Hill 1 #> #> [[76]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Shaak Ti 2 #> #> [[77]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Grievous 1 #> #> [[78]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Tarfful 1 #> #> [[79]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Raymus Antilles 2 #> #> [[80]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Sly Moore 2 #> #> [[81]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Tion Medon 1 #> #> [[82]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Finn 1 #> #> [[83]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Rey 1 #> #> [[84]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Poe Dameron 1 #> #> [[85]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 BB8 1 #> #> [[86]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Captain Phasma 1 #> #> [[87]] #> # A tibble: 1 × 2 #> name n_vehicles #> <chr> <int> #> 1 Padmé Amidala 3 ``` ] -- .rightcol[ Use `map_df()` to merge the data frames ```r *map_df(sw_people, \(x) tibble( name = x$name, n_vehicles = length(x$films) ) ) ``` ``` #> # A tibble: 87 × 2 #> name n_vehicles #> <chr> <int> #> 1 Luke Skywalker 5 #> 2 C-3PO 6 #> 3 R2-D2 7 #> 4 Darth Vader 4 #> 5 Leia Organa 5 #> 6 Owen Lars 3 #> 7 Beru Whitesun lars 3 #> 8 R5-D4 1 #> 9 Biggs Darklighter 1 #> 10 Obi-Wan Kenobi 6 #> # … with 77 more rows ``` ] --- class: inverse
15
:
00
## Your turn Try to answer these questions: 1. Which SW film has the most characters? (use `sw_films`) 2. Which SW species has the highest average lifespan? (use `sw_species`) 3. Which GoT character(s) have been played by multiple actors? (use `got_chars`) --- ## Sometimes you really need do something on each row Use a `for` loop to iterate across each row in a data frame: ```r for (i in 1:nrow(df)) { row <- df[i,] # Do stuff with row } ``` --- ## .center[Example: tagging a new daily covid case record] ```r covid_dc <- read_csv(here::here('data', 'us_covid.csv')) %>% filter(state == 'District of Columbia') %>% select(-state) head(covid_dc) ``` ``` #> # A tibble: 6 × 6 #> date day cases_daily deaths_daily cases_total deaths_total #> <date> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 2020-01-23 1 0 0 0 0 #> 2 2020-01-24 2 0 0 0 0 #> 3 2020-01-25 3 0 0 0 0 #> 4 2020-01-26 4 0 0 0 0 #> 5 2020-01-27 5 0 0 0 0 #> 6 2020-01-28 6 0 0 0 0 ``` --- ## .center[Example: tagging a new daily covid case record] .leftcol[ Initialize new column ```r covid_dc$new_record <- FALSE glimpse(covid_dc) ``` ``` #> Rows: 403 #> Columns: 7 #> $ date <date> 2020-01-23, 2020-01-24, 2020-01-25, 2020-01-26, 2020-01-… #> $ day <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17… #> $ cases_daily <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … #> $ deaths_daily <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … #> $ cases_total <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … #> $ deaths_total <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, … #> $ new_record <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, F… ``` ] .rightcol[ Now loop through each row and check if a new record is met ```r record <- 0 for (i in 1:nrow(covid_dc)) { # Get the nubmer of cases on row i num_cases <- covid_dc[i,]$cases_daily # Check if new record is met if (num_cases > record) { # Update new record in covid_dc covid_dc[i, ]$new_record <- TRUE # Update new record record <- num_cases } } ``` ] --- <center> <img src="images/covid-record.png" width=840> </center> --- ## Preview [HW 11](https://p4a.seas.gwu.edu/2023-Spring/hw/11-programming-with-data.html)