我在按照this question選擇的答案時遇到問題。我試圖抓取的表格是this list of U.S. state populations。維基百科故障刮表
library(XML)
theurl <- "http://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population"
tables <- readHTMLTable(theurl)
n.rows <- unlist(lapply(tables, function(t) dim(t)[1]))
這是我得到的錯誤..
Error: failed to load external entity "http://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population"
是怎麼回事?
(注 - 雖然我在尋找解決這個錯誤,如果你可以點我得到的人口數據我會很感激的更簡單的方法)
Wikipedia允許免費下載他們的整個數據庫... https://en.wikipedia.org/wiki/Wikipedia:Database_download這應該會減少已經超出網絡服務器 – ScottMcGready
err,你可以按照參考鏈接對於有問題的數據,可在頁面底部找到,然後轉到[參考站點](http://www.census.gov/popest/data/state/totals/2013/index.html),也稱爲作爲人口普查,並下載其中包含的csv或xls。 –
@ScottMcGready,你必須有一個大的外部HD。 :)這不是一個小的下載,你只是在那裏提供一個50行的表格,其中包含一些感興趣的列。 –