我正在使用“R 中的数据混搭”学习 R,但我无法在 p 上获得示例。5上班。我使用的代码是这样的:
# Install and load RCurl
install.packages("RCurl")
library("RCurl")
# Install and load the XML package
install.packages("XML")
library("XML")
# Download file and parse it
appid<- 'ucVVQzLV34GQR4ppLwbdW6G8cCSZDoCBqAc53NXsWB3gXkmP1I4epLwMxboV.PfADi_2ubr2A7Cg8FO4Z3xVxxujza2FJ 8M-'
street<-"11408 Bellflower Road"
RCurl<-paste(
"http://local.yahooapis.com/MapsService/V1/geocode?appid=",
appid,
"&street=",
URLencode(street),
"&city=Cleveland&state=OH"
,sep="")
#xmlResult<-xmlTreeParse(requestUrl,isURL=TRUE)
xmlResult<-xmlTreeParse(getURL(RCurl))
#Print the output
str(xmlResult)
但是当我这样做时,我没有得到以下结果:
List of 2
$ doc:List of 3
..$ file :List of 2
.. ..$ text : Named list()
.. .. ..- attr(*, "class")= chr [1:5] "XMLTextNode" "XMLNode" "RXMLAbstractNode" "XMLAbstractNode" ...
.. ..$ Message:List of 1
.. .. ..$ text: Named list()
.. .. .. ..- attr(*, "class")= chr [1:5] "XMLTextNode" "XMLNode" "RXMLAbstractNode" "XMLAbstractNode" ...
.. .. ..- attr(*, "class")= chr [1:4] "XMLNode" "RXMLAbstractNode" "XMLAbstractNode" "oldClass"
.. ..- attr(*, "class")= chr [1:4] "XMLNode" "RXMLAbstractNode" "XMLAbstractNode" "oldClass"
..$ version : Named list()
.. ..- attr(*, "class")= chr [1:5] "XMLCommentNode" "XMLNode" "RXMLAbstractNode" "XMLAbstractNode" ...
..$ children:
Error in x$children[[...]] : subscript out of bounds
我究竟做错了什么?