Our professor keeps giving us assignments to work with in R but instead of giving us easier data we normally have to pull from the web.
This block of code does that:
library(rvest)
url <- "https://www.supremecourt.gov/opinions/slipopinion/18"
page <- read_html(url)
table <- html_table(page, fill = FALSE, trim = TRUE)
However this also gets included in the table data:
table [[1]] X1 1 SEARCH TIPS\r\n Search term too short \r\n Invalid text in search term. Try again X2 1 ADVANCED SEARCHDOCKET SEARCH
So I am having a hard time understanding how to format this data into a data frame because doing something like as.data.frame(table)
gives me this error,
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 1, 11, 8, 7, 2
html_nodes("table")
with a selector for the desired tables, before usinghtml_table
. - neilfws