将zip_distance应用于每一行
我有一个带有两列的数据框,zip
和cszip
。我正在尝试使用以下方式将函数应用于每一行:
dist <- apply(vf, 1, zip_distance(zip, CSZip, lonlat = TRUE, units = "meters"))
但是我得到此错误:
Error in as.character(zipcode_a) :
cannot coerce type 'closure' to vector of type 'character'
zip_distance来自zipcoder软件包。
这就是5行VF的样子:
Zip | CSZIP |
---|---|
91723 | 90048 |
90814 | 90048 |
91604 | 90048 |
90048 | 90805 90048 |
90048 90255 | 90048 |
I have a dataframe with two columns, zip
and CSZip
. I am trying to apply a function to each row using:
dist <- apply(vf, 1, zip_distance(zip, CSZip, lonlat = TRUE, units = "meters"))
But I get this error:
Error in as.character(zipcode_a) :
cannot coerce type 'closure' to vector of type 'character'
zip_distance is from the ZipCodeR package.
This is what 5 rows of vf looks like:
zip | CSZip |
---|---|
91723 | 90048 |
90814 | 90048 |
91604 | 90048 |
90805 | 90048 |
90255 | 90048 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Zipcoder具有一些时髦的行为。
有时,使用循环更容易:
The ZipcodeR is has some funky behavior.
Sometimes it is just easier to use a for loop:
也许这就是您需要的:
Maybe this is what you need: