2014-09-22 54 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/'))