0
votes

I am trying to convert a table from a website into a table I could read in R.

url <- "https://www.pro-football-reference.com/teams/cle/2020.htm#all_games"

pfr_raw <- url %>%
     read_html() %>%
     html_table() %>%
     as.data.frame()

But when I do this it throws this error -> `Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 17, 3'

The thing is if I use the link but 2019 instead of 2020 it works. How do I fix this issue? Thank You

1

1 Answers

0
votes

It is a list of data.frame from the html_table and not all the columns are present in all data.frame. So, it may be better to use bind_rows

library(dplyr)
library(xml2)
library(rvest

out <- url %>%
 read_html() %>%
 html_table() %>% 
 bind_rows

dim(out)
#[1] 31 60