我认为这就是÷anti_join÷的目的。我正在开发一个功能,该功能可迭代Twitter追随者争夺用户向量。似乎我的所有代码都正确编码,因为当我运行它时,我得到的错误是:
UseMethod(“ anti_join”)中的错误: 没有将“ anti_join”的适用方法应用于“字符”类的对象
这是我的代码:
#packages
packages <- c("chron",
"dplyr",
"rtweet")
packages.l <- length(packages)
#install packages
for (i in 1:packages.l) {
install.packages(packages[i])
}
#add to library
for (i in 1:packages.l) {
library(packages[i], character.only = TRUE)
}
#oauth
app.name <- #app name
a.secret <- #access secret
a.token <- #access token
c.key <- #consumer key
c.secret <- #consumer secret
#rtweet
twitter_token <- create_token(
app = app.name,
consumer_key = c.key,
consumer_secret = c.secret
)
grabFollowers <- function(seed) {
#loop on seed
seed.length <- length(seed)
output <- c(NULL)
for (i in seed.length) {
userids <- get_followers(
seed[i],
n = 1000000000,
retryonratelimit = TRUE
)
userids.length <- length(userids)
pull.length <- 0
user.followers <- c(NULL)
#get usernames
while (userids.length > pull.length) {
j <- pull.length + 1
batch <- lookup_users(
userids$user_id[j:userids.length]
)
user.followers <- c(user.followers, batch$screen_name)
pull.length <- length(user.followers)
}
#remove duplicates and add to output (error here)
user.followers <- anti_join(user.followers, seed)
output <- c(output, user.followers)
output <- unique(output)
}
print(output)
}
anti_join
不能识别字符串还是我不知道的其他错误?