首页 > 解决方案 > UseMethod(“read_xml”)中的错误:没有适用于“read_xml”的方法应用于“list”类的对象

问题描述

我有一些文本文件的向量。这是我如何处理的

text[1] <- read_html("link1") text[2] <- read_html("link2") text[3] <- read_html("link3") . . until text [100]

我想创建一个具有以下内容的语料库:

x <- list(text[i]) z <- lapply(x, read_html)

我有

Error in UseMethod("read_xml") : no applicable method for 'read_xml' applied to an object of class "list"

在该错误之前,它是逻辑数据,我已将 text[i] 转换为以下内容

text[i] <- as.character (text[i])

另外,我得到了

number of items to replace is not a multiple of replacement lengthnumber of items to replace is not a multiple of replacement

我不知道发生了什么。谢谢。

标签: rtext

解决方案


我试过了:

x <- rep("https://www.google.com/", 3)
z <- lapply(x, read_html)

它有效吗?


推荐阅读