Ich möchte die Ranking-Punktzahl von einigen Filmen erwerben, und nicht wissen, wie man das Problem mit "subscript out of bounds" zu beheben. Hier ist mein 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")
Und der Fehler wie:
Error in reslist$subjects[[1]] : subscript out of bounds
Haben Sie die API-Dokumentation richtig gelesen? – vagabond