2014-09-22 55 views
2

的第一個例子。這是我的會話信息:無法從XML庫複製中的R

> sessionInfo() 
R version 3.1.1 (2014-07-10) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 

locale: 
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C       
[5] LC_TIME=English_United States.1252  

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] reshape2_1.4 ggplot2_1.0.0 XML_3.98-1.1 dplyr_0.2  

loaded via a namespace (and not attached): 
[1] assertthat_0.1 colorspace_1.2-4 digest_0.6.4  grid_3.1.1  gtable_0.1.2  
[6] magrittr_1.0.1 MASS_7.3-33  munsell_0.4.2 parallel_3.1.1 plyr_1.8.1  
[11] proto_0.3-10  Rcpp_0.11.2  scales_0.2.4  stringr_0.6.2 tools_3.1.1  

是否需要安裝其他庫?

+0

你能還添加了產量? – nrussell 2014-09-22 14:24:50

+0

有時會出現此錯誤。我建議重新啓動R會話,如果這樣做沒有幫助,您可能需要將示例複製到他們自己的文件中。然後添加一行使用'RCURl'包中的'getURL'來獲取內容。另外,如果您一直使用大量XML文檔,則使用'gc()'和'free()' – 2014-09-22 15:25:07

+0

以下是R-help的相關主題:http://r.789695.n4.nabble.com/htmlParse - 從-XML庫 - 工作 - 偶爾,在最相同的代碼,td4661943.html。 XML的作者直接回答這個問題 – 2014-09-22 15:28:35

回答

0

發生此錯誤時,請加載httr程序包並調用它。下面是我自己的工作的例子,其中第一XML調用返回的錯誤,但HTTR電話沒有:從調用`sessionInfo()`

require(httr) 

doc <- htmlTreeParse('http://www.lewisthomason.com/locations/', useInternal = TRUE) 
doc <- content(GET('http://www.lewisthomason.com/locations/'))