1

I'm trying to get 2018 'Player Standard Batting' table from baseball-reference.com. there are multiple tables on the URL page and when i run the following code. I'm only able to get the first table in the table list. I need the second table which is the player standard batting.

library(rvest)
url <- "https://www.baseball-reference.com/leagues/MLB/2018-standard-batting.shtml"
pg <- read_html(url)
tb <- html_table(pg, fill = TRUE)
df_batting <- tb[[1]]
JJJ
  • 1,009
  • 6
  • 19
  • 31
JAGIMAC
  • 21
  • 4
  • If you view the HTML source, you'll see that the other tables are in a comment. The answer is contained here: https://stackoverflow.com/questions/40616357/how-to-scrape-tables-inside-a-comment-tag-in-html-with-r – bloodyknuckles Jul 13 '19 at 01:17

0 Answers0