Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Scraping In R readHTMLTable error with function

I'm teaching myself some basic table web scraping techniques in R. But I see the error when running the function readHTMLTable.

unable to find an inherited method for function ‘readHTMLTable’ for signature ‘"NULL"’

I am specifically trying to read the data in the second table. I've already checked the page source to make sure that the table is formatted with <table> and <td>

release_table <- readHTMLTable("https://www.comichron.com/monthlycomicssales/1997/
                               1997-01.html", header=TRUE, which=2,stringsAsFactors=F)

I would expect the output to mirror the text in the second table.

like image 833
imurdo13 Avatar asked Feb 12 '26 04:02

imurdo13


1 Answers

We can use rvest to get all the tables.

url <- "https://www.comichron.com/monthlycomicssales/1997/1997-01.html"
library(rvest)
tab <- url %>%  read_html() %>%  html_table()

I think what you are looking for is tab[[1]] or tab[[4]].

like image 121
Ronak Shah Avatar answered Feb 15 '26 22:02

Ronak Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!