当前,我正在RStudio中编写IMDB电影数据库API。我已经写了下载电影的代码,但过一会儿,尽管看上去就像上一本,但一栏中的值还是有错误的。有错误:
错误:列Ratings
的长度必须为1,而不是0
library(tidyverse)
library(imdbapi)
movies <- read.csv("movie_titles.csv", header = F)
names(movies) <- c("no", "year", "name")
movies_10 <- movies %>%
mutate_all(as.character) %>%
mutate(year=as.numeric(year)) %>%
filter(year %in% c(1994:2004))
omdb_api_key(force = T) #708d1c87
movies_imdb <- data.frame()
for(i in 1:100000){
m <- find_by_title(title = movies_10$name[i], year_of_release = movies_10$year[i], api_key = omdb_api_key())
if(nrow(m) > 0){
movies_imdb <- union_all(movies_imdb, m)
}
m <- find_by_title(title = movies_10$name[i], year_of_release = movies_10$year[i], api_key = omdb_api_key())
}
我已经尝试删除此列,因为我不需要这一列。我也听说过trycatch