I want to acquire the ranking score of some movies, and not knowing how to fix the problem with "subscript out of bounds". Here is my code.
movieScoreapi <- function(x) {
api <- "https://api.douban.com/v2/movie/search?q={"
url <- paste(api, x, "}", sep = "")
res <- getURL(url)
reslist <- fromJSON(res)
name <- reslist$subjects[[1]]$title
score <- reslist$subjects[[1]]$rating$average
return(list(name = name, score = score))
}
movieScoreapi("Life is beautiful")
And the error is like :
Error in reslist$subjects[[1]] : subscript out of bounds