Xml R中的数据mashup:;下标越界“;
我正在用“R中的数据mashup”学习R,但我无法在p上得到这个例子。5.去上班。我使用的代码如下:Xml R中的数据mashup:;下标越界“;,xml,r,http,yahoo,Xml,R,Http,Yahoo,我正在用“R中的数据mashup”学习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<- 'ucVVQzLV34G
# 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)
我做错了什么?那个API已经被弃用了。请尝试以下方法:
library("RCurl")
library("XML")
appid <- 'ucVVQzLV34GQR4ppLwbdW6G8cCSZDoCBqAc53NXsWB3gXkmP1I4epLwMxboV.PfADi_2ubr2A7Cg8FO4Z3xVxxujza2FJ 8M-'
address <- paste("11408+Bellflower+Road", "Cleveland", "OH", sep=",+")
urlRequest <- paste("http://where.yahooapis.com/geocode?q=",
address, appid=appid, sep = "")
doc <- xmlToList(xmlTreeParse(urlRequest)) # Convert to List
str(doc)
可能什么都没有。URL似乎返回了404的错误,所以可能是错误的还是过时的?南加州大学(USC)也提供了一个不错的地理编码服务。它提供了许多Google没有的选项,例如包括普查信息(普查区域、区块等,地址在其中),并为返回对象提供了许多选项,例如CSV(可以添加一行以创建完整的CSV文档)和KML(以Google Earth或Maps格式查看)。带文档的URL位于,谢谢!真是太棒了。我会再多玩一点,看看是否可以进入下一个阶段!=)
library("RCurl")
library("XML")
appid <- 'ucVVQzLV34GQR4ppLwbdW6G8cCSZDoCBqAc53NXsWB3gXkmP1I4epLwMxboV.PfADi_2ubr2A7Cg8FO4Z3xVxxujza2FJ 8M-'
address <- paste("11408+Bellflower+Road", "Cleveland", "OH", sep=",+")
urlRequest <- paste("http://where.yahooapis.com/geocode?q=",
address, appid=appid, sep = "")
doc <- xmlToList(xmlTreeParse(urlRequest)) # Convert to List
str(doc)
List of 7
$ Error : chr "0"
$ ErrorMessage: chr "No error"
$ Locale : chr "us_US"
$ Quality : chr "87"
$ Found : chr "1"
$ Result :List of 29
..$ quality : chr "87"
..$ latitude : chr "41.511326"
..$ longitude : chr "-81.605583"
..$ offsetlat : chr "41.511230"
..$ offsetlon : chr "-81.605453"
..$ radius : chr "2900"
..$ name : NULL
..$ line1 : chr "11408 Bellflower Rd"
..$ line2 : chr "Cleveland, OH 44106"
..$ line3 : NULL
..$ line4 : chr "United States"
..$ house : chr "11408"
..$ street : chr "Bellflower Rd"
..$ xstreet : NULL
..$ unittype : NULL
..$ unit : NULL
..$ postal : chr "44106"
..$ neighborhood: NULL
..$ city : chr "Cleveland"
..$ county : chr "Cuyahoga County"
..$ state : chr "Ohio"
..$ country : chr "United States"
..$ countrycode : chr "US"
..$ statecode : chr "OH"
..$ countycode : NULL
..$ uzip : chr "44106"
..$ hash : chr "BFBDCAB96C2CB175"
..$ woeid : chr "12776632"
..$ woetype : chr "11"
$ .attrs : Named chr "1.0"
..- attr(*, "names")= chr "version"