I've scraped two tables into R, trimmed them, and now I seek to create new tables by splitting one of the columns of the originals into two. To do this, I've written the following code:
page.201702050atl = read_html("http://www.pro-football-reference.com/boxscores/201702050atl.htm")
comments.201702050atl = page.201702050atl %>% html_nodes(xpath = "//comment()")
home.drives.201702050atl = comments.201702050atl[43] %>% html_text() %>% read_html() %>% html_node("#home_drives") %>% html_table()
home.drives.201702050atl.a = home.drives.201702050atl[ , 2:8]
LOS.home.201702050atl = t(data.frame(strsplit(as.character(home.drives.201702050atl.a$LOS), " ", 2)))
LOS.vis.201702050atl = t(data.frame(strsplit(as.character(home.drives.201702050atl.a$LOS), " ", 2)))
I've run this code countless times on countless other tables; but, on these two (nearly identical) tables, I seem to be having a problem that I don't understand:
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 2, 0
Can someone please translate this error message into English for me? What is wrong in this particular case? Finally, how do I fix it?
EDIT:
There is a missing cell in row 5 of home.drives.201702050atl. Initially I thought this might be the problem; however, that is why I included the second table. In the second table, there is no missing cell; and yet, I encounter the same error. While it is similar to that of the first table, I did not include the entirety of the coding of the second table in my original post. Please find it below:
> page.201702050atl = read_html("http://www.pro-football-reference.com/boxscores/201702050atl.htm")
> comments.201702050atl = page.201702050atl %>% html_nodes(xpath = "//comment()")
> vis.drives.201702050atl = comments.201702050atl[44] %>% html_text() %>% read_html() %>% html_node("#vis_drives") %>% html_table()
> vis.drives.201702050atl.a = vis.drives.201702050atl[ , 2:8]
> LOS.vis.201702050atl = t(data.frame(strsplit(as.character(home.drives.201702050atl.a$LOS), " ", 2)))
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 2, 0