R语言的RedditExtractoR:错误-下标超出界限

5ssjco0h  于 2022-12-20  发布在  R语言
关注(0)|答案(1)|浏览(195)

我的目标是使用RedditExtractoR抓取reddit用户的帖子。下面是我的代码:

library(tidyverse)
library(RedditExtractoR)
user <- "a_guy828"
user_content <- get_user_content(user) # It shows error that page[[content_type]]:subscript out of bounds
user_threads<-user_content[[user]]$threads
view(user_threads)

user_content <- get_user_content(user)中工作时,我收到错误消息“subscript out of bounds”我该如何解决它?

2izufjch

2izufjch1#

我也有这个问题,我不知道为什么。
但如果可以排除这些用户,则在提取其他用户时跳过这些用户可能会有所帮助(尽管这并不能解决问题)

# create a list the extraction to save inside
users_extracted <- list() 

# Function for the extraction
get_data <- function(x) {
    get_user_content(x)
}

# This is the workhorse to bring the data in (while skipping those users with errors)
get_data2 <- possibly(get_data, otherwise = NA)

# Run the loop with your list of user names (list_of_users_names)
for(i in list_of_users_names) {
    users_extracted[i] <- get_data2(i)
}

相关问题