1

我正在尝试将http://killedbypolice.net/上的表格导入 R。表格很大并且合并了单元格,所以它并不简单。我的代码的最后一步永远不会结束。如何让表格进入我的 R 会话?

这是我正在尝试的:

url <- "http://killedbypolice.net/"
# read in the web page
tmp1 <- read_html(url, options = "HUGE") 

# Extract the table from the web page, I used Chrome's inspector to
# identify the XPath here, following these instructions
# http://blog.corynissen.com/2015/01/using-rvest-to-scrape-html-table.html 
tmp2 <- html_nodes(tmp1, xpath='/html/body/center/font/font/font/font/font/font/table')

# Convert HTML table to a data frame 
tmp3 <- html_table(tmp2, fill = TRUE)

问题是最后一行永远运行。我猜它挂在合并的单元格上?

是否有另一种方法可以将 HTML 表格放入数据框中?

4

0 回答 0