I'm attempting to do something very similar to this question.
However, I need a slightly different table. Sounds easy enough, right? But I've run into a weird case of "same code appears to work differently in two instances." Here's a simple test example.
If I run the below code, the first instance runs fine. The second returns the following error:
Error in UseMethod("html_table") : no applicable method for 'html_table' >applied to an object of class "xml_missing"
The table names seem consistent with what I'm seeing in SelectorGadget.
library(rvest)
url_splits <-"http://www.basketball-reference.com/players/i/ingrabr01/splits/"
stats_splits <- read_html(url_splits) %>%
html_node("table#splits") %>%
html_table()
url_college <-"http://www.basketball-reference.com/players/i/ingrabr01.html"
stats_college <- read_html(url_college) %>%
html_node("table#all_college_stats") %>%
html_table()
Obviously something must be different but I can't tell what it is. I tried using the xpath fro Selector instead with the same result. Any ideas?