I'm new here. I wanted to check working my old R script (from april 2021) and I know, that it not working now. I looked for solve in the Internet, upgraded my R language and needed libraries and it still not working. In april 2021 everything working good, without problems.
This is my code:
library(rvest)
library(stringr)
{
cleaning = function()
{
file_html <<- read_html("https://www.nbp.pl/homen.aspx?f=/kursy/RatesA.html",
encoding = "UTF-8")
table_html <<- html_node(file_html, ".pad5")
table_r <<- html_table(table_html, fill = TRUE, dec = ",")
currencies <<- data.frame(table_r)
colnames(currencies) <<- c("currency_name", "currency_code", "mid_rate")
}
cleaning()
}
After run this code I get this error:
Error in UseMethod("html_table") :
no applicable method for 'html_table' applied to an object of class "xml_missing"
CodePudding user response:
The reason is that call html_node(file_html, ".pad5")
returns a missing element, because there is no element of id .pad5
at the website. They probably have changed names of the elements, if you claim that it used to work.