Created
July 22, 2019 01:31
-
-
Save JosiahParry/29efa1c7334c5e47a3c8f4c830f6fc64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(jsonlite) | |
res <- GET("http://api.themoviedb.org/3/discover/movie?release_date.gte=2017-12-01&release_date.lte=2017-12-31&api_key=606aaffd7ca10f0b80804a1f0674e4e1&page=1") %>% | |
content("text") %>% | |
fromJSON() | |
int0_to_na <- function(x) { | |
#https://stackoverflow.com/questions/21218041/replace-integer0-by-na | |
if (length(x) == 0) | |
return(NA) | |
return(x) | |
} | |
res %>% | |
as_tibble() %>% | |
jsonlite::flatten() %>% | |
as_tibble() %>% | |
unnest() %>% | |
mutate(x = map_int(results.genre_ids, int0_to_na)) %>% | |
select(results.genre_ids, x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment