Skip to content

Commit fc90f22

Browse files
committed
use cran version of rwars
1 parent 3216c61 commit fc90f22

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

code/swapi.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## http://swapi.co/
2-
# install_github("ironholds/rwars", ref = "0.5.0")
2+
# install.packages("rwars")
33
library(rwars)
44
library(purrr)
55

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

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

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

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

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

data/swapi.rda

5.29 KB
Binary file not shown.

0 commit comments

Comments
 (0)