Skip to content

Commit

Permalink
use cran version of rwars
Browse files Browse the repository at this point in the history
  • Loading branch information
cwickham committed May 31, 2017
1 parent 3216c61 commit fc90f22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/swapi.R
@@ -1,5 +1,5 @@
## http://swapi.co/
# install_github("ironholds/rwars", ref = "0.5.0")
# install.packages("rwars")
library(rwars)
library(purrr)

Expand All @@ -16,11 +16,12 @@ get_all <- function(x = NULL, old_data = NULL, fun, ...){

entities <- c("species", "people", "films", "vehicles", "starships",
"planets")
entity_funs <- map(paste0("get_all_", entities), match.fun)

all_ents <- map(entities,
~ get_all(fun = match.fun(paste0("get_all_", .x)), parse_result = TRUE))
all_ents <- map(entity_funs, ~ get_all(fun = .x, parse_result = TRUE))

all_ents <- map(all_ents, ~ transpose(.x)[["results"]] %>% flatten())
all_ents_res <- map(all_ents,
~ transpose(.x)[["results"]] %>% flatten())

map2(entities, all_ents, ~ assign(.x, .y, envir = globalenv()))

Expand Down
Binary file modified data/swapi.rda
Binary file not shown.

0 comments on commit fc90f22

Please sign in to comment.