简体   繁体   English

胁迫论证不是原子载体(无休止地重复)

[英]coercing argument is not an atomic vector (repeating endlessly)

Newbie question here. 这里有新手问题。 I'm trying to run some code that will extract the usernames and dates from a list of assembled web pages. 我正在尝试运行一些代码,这些代码将从汇编的网页列表中提取用户名和日期。 This was working perfectly fine before, but now when I run the code I keep getting the error "coercingargument is not an atomic vector" which repeats endlessly. 这之前工作得很好,但是现在当我运行代码时,我不断得到错误“coercinggugument不是原子向量”,它无休止地重复。

I've tried reviewing previous answers here but nothing seemed to quite work. 我试过在这里回顾一下以前的答案,但似乎没有什么工作。 I can't understand why it suddenly stopped working even though nothing has changed. 我无法理解为什么它突然停止工作,即使没有任何改变。 My feeling is I either removed a library it needed or something hasn't quite reset. 我的感觉是我要么删除它需要的库还是没有完全重置的东西。 Any help would be warmly appreciated. 任何帮助将受到热烈的赞赏。

# COLLECT THE DATES
for (i in urls3) {
  addurl <- i
  discussion <- read_html(i, timeout = 1000000000)
  usernames <- discussion %>% 
  html_nodes(".lia-component-message-view-widget-author-username a") %>% 
  html_text()
  all.usernames <- append(all.usernames, usernames)
  datetime <- discussion %>% 
  html_nodes(".local-friendly-date")
  datetime <- str_extract(datetime, "[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2} [A-Z]{2}")
  datetime <- parse_date_time(datetime, "%Y-%m-%d %H:%M:%p", tz = "US/Eastern")
  datetime <- as.character(datetime)
  date.posted <- datetime[1]
  date.replied <- datetime[2]
  date.difference <- difftime(datetime[2],datetime[1], units=c("mins"))

  new.table <- rbind(new.table,c(addurl, date.posted, date.replied, date.difference))
}

The expected results would be a table with the URL, date posted, date replied, and date difference. 预期结果将是一个表格,其中包含URL,发布日期,回复日期和日期差异。

The actual results are "argument is not an atomic vector; coercingargument is not an atomic vector; coercingargument is not an atomic vector; coercingargument is not an atomic vector; ..." 实际结果是“参数不是原子矢量;强制参数不是原子矢量;强制参数不是原子矢量;强制参数不是原子矢量; ......”

You need these packages to make your code work : 您需要这些包来使您的代码工作:

library(textreadr)
library(dplyr)
library(rvest)
library(stringr)
library(lubridate)

You could ckeck where in the for loop it is bugging and last be careful when you concatenate to have the same object in the two sides. 你可以知道在for循环中它在哪里被窃听,并且当你连接以在双方拥有相同的对象时最后要小心。

append, c, rbind

You have two package with read_html function be careful. 你有两个包含read_html函数的包小心。 You will gained clearness to give a more syntetic example. 你将获得一个更清晰的例子。 I hope it will help you. 我希望它会对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM