首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Match.fun错误(FUN):

Match.fun错误(FUN):
EN

Stack Overflow用户
提问于 2014-10-06 08:06:17
回答 1查看 6.2K关注 0票数 0

软件包: ggmap、ggplot2 plyr

我使用了mapdist函数来计算两个邮政编码之间的距离。

我希望将mapdist函数应用于列表并导出到csv。文件。

下面是iv尝试过的。

运行mapdist并导出

代码语言:javascript
复制
data <- mutate(dataset, from = NA, to = NA, m = NA, km = NA, miles = NA)

lapply(dataset, mapdist(PostcodeA, PostcodeB, mode = "driving"))

Error in match.fun(FUN) : 
'mapdist(PostcodeA, PostcodeB, mode = "driving")' is not a function, character or symbol 

dataset <- data.frame(lapply(dataset, as.character))

write.csv(dataset, "Rexport.csv")`

我在match.fun(FUN)中遇到一个错误:

有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2014-10-06 08:19:02

它对我有效(我生成了一些数据):

代码语言:javascript
复制
library(rvest)
library(stringr)

# get America's most expensive zip codes
pg <- html("http://www.forbes.com/2009/08/26/most-expensive-zip-codes-lifestyle-real-estate-zip_full-list.html")
zips <- pg %>% html_nodes("td a") %>% html_text() %>% str_extract("[[:digit:]]+")

from <- head(zips)
to <- tail(zips)

data_set <- mapdist(from, to, mode="driving")
data_set

##    from    to       m       km      miles seconds    minutes      hours
## 1 07620 95054 4733283 4733.283 2941.26206  151391 2523.18333 42.0530556
## 2 94027 95148   48750   48.750   30.29325    2464   41.06667  0.6844444
## 3 10014 95060 4787194 4787.194 2974.76235  154148 2569.13333 42.8188889
## 4 91008 94089  581823  581.823  361.54481   19609  326.81667  5.4469444
## 5 90210 63124 2949509 2949.509 1832.82489   92594 1543.23333 25.7205556
## 6 92067 02714 4892815 4892.815 3040.39524  157615 2626.91667 43.7819444
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26208507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档