r语言html文件生成pdf失败,【已解决】R语言出错:Error: could not find function "htmlParse"...

【问题】

折腾:

期间,用如下代码:> retHtml

> parsedHtml = htmlParse(retHtml, asText=TRUE,encoding="GBK")

Error: could not find function "htmlParse"

结果出错:Error: could not find function "htmlParse"

如图:

cc35b909adc6af1dc3b41ab111725ae4.png

【解决过程】

1.本来打算参考之前的:

去安装库的,但是发现,不知道htmlParse属于哪个库。

2.后来是搜:

R语言 htmlParse

而找到:

而想到是XML库的。

所以再去安装一下XML库。

3.代码:> install.packages("XML")

trying URL 'http://mirrors.ustc.edu.cn/CRAN/bin/windows/contrib/3.0/XML_3.98-1.1.zip'

Content type 'application/zip' length 4288136 bytes (4.1 Mb)

opened URL

downloaded 4.1 Mb

package ‘XML’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in

C:\Users\CLi\AppData\Local\Temp\RtmpIRchyS\downloaded_packages

>

如图:

5324110b572c986b6b68d40230eb3443.png

922c941cb76a53213d56cdcc2cb89326.png

4.然后再试试之前的代码:

结果还是不行:> parsedHtml = htmlParse(retHtml, asText=TRUE,encoding="GBK")

Error: could not find function "htmlParse"

5.想起来参考别人代码要先去导入此库,然后再运行就可以了:> require("XML")

Loading required package: XML

> parsedHtml = htmlParse(retHtml, asText=TRUE,encoding="GBK")

如图:

8ed2e98124311690eac19789aa3cbc7c.png

【总结】

1.htmlParse是R语言中的XML库中的函数。

2.使用函数之前,需要导入对应的库,写法是:require("XML")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值