SWAPI är ett API med data över Star Wars filmerna som kan hämtas i JSON-format. Det finns ett R-paket rwars som kan användas för att hämta data från detta API, jag vet inte om det är till någon hjälp men det skall inte användas i uppgiften.

Ett exempel på datauttag ges av följande kod, läs mer på SWAPIs dokumentation.

library(httr)
library(jsonlite)
response <- GET("https://swapi.co/api/people/1/")
luke <- content(response, "text") %>% fromJSON()
str(luke)
## List of 16
##  $ name      : chr "Luke Skywalker"
##  $ height    : chr "172"
##  $ mass      : chr "77"
##  $ hair_color: chr "blond"
##  $ skin_color: chr "fair"
##  $ eye_color : chr "blue"
##  $ birth_year: chr "19BBY"
##  $ gender    : chr "male"
##  $ homeworld : chr "https://swapi.co/api/planets/1/"
##  $ films     : chr [1:5] "https://swapi.co/api/films/2/" "https://swapi.co/api/films/6/" "https://swapi.co/api/films/3/" "https://swapi.co/api/films/1/" ...
##  $ species   : chr "https://swapi.co/api/species/1/"
##  $ vehicles  : chr [1:2] "https://swapi.co/api/vehicles/14/" "https://swapi.co/api/vehicles/30/"
##  $ starships : chr [1:2] "https://swapi.co/api/starships/12/" "https://swapi.co/api/starships/22/"
##  $ created   : chr "2014-12-09T13:50:51.644000Z"
##  $ edited    : chr "2014-12-20T21:17:56.891000Z"
##  $ url       : chr "https://swapi.co/api/people/1/"
get_character("https://swapi.co/api/people/1/")
##             Name Species
## 1 Luke Skywalker   Human
get_cast("https://swapi.co/api/films/1/") %>% 
    head(2) 
##             Name Species
## 1 Luke Skywalker   Human
## 2          C-3PO   Droid