Error: could not find function "read_html"

Demi Kalia picture Demi Kalia · Jun 20, 2015 · Viewed 14.3k times · Source

I use this code

library(rvest)
url<-read_html("http://en.wikipedia.org/wiki/Brazil_national_football_team")

And I take back this error

Error: could not find function "read_html"

Any idea what's going wrong with this?

Also in case of multiple links like this

library(rvest)
urls<-html("https://en.wikipedia.org/wiki/Financial_crisis",
"https://en.wikipedia.org/wiki/Inflection",
"https://en.wikipedia.org/wiki/Financial_crisis_of_2007%E2%80%9308"
)

I receive this:

 Error: is.config(config) is not TRUE

How can I make it to work? How is it if I have this links into a txt file?

Answer

yxtay picture yxtay · Oct 10, 2015

The documentation probably referred to the read_html() function in the xml2 package which is written by the same author, Hadley Wickham, after the initial publication of the rvest package.

Therefore, you will have to install and load the xml2 package as follows:

install.packages('xml2')
library('xml2')

url<-read_html("http://en.wikipedia.org/wiki/Brazil_national_football_team")