I am trying to scrape a table from OECD website about FDI b/w 2005-2021. But when I run the code for the table using html_table, it's returning a list of 0.
I tried the same code with a different table and it worked fine, but this one is not working.
library(rvest)
library(dplyr)
link = "https://data.oecd.org/fdi/fdi-flows.htm#indicator-table"
page = read_html(link)
table = page %>% html_nodes("table.DataTable") %>% html_table()
the above code is returning 'table2: List of 0' and consequently converting it to a table with %>% . [[1]] is not working because it gives the following error:
Error in .[[1]] : subscript out of bounds