【发布时间】:2019-03-04 08:37:12
【问题描述】:
Yelp Fusion API 允许您在 R 中一次提取 50 行,但您可以通过更改偏移量来循环执行此操作。如果我使用
library(yelpr)
Key <- ***
NYC_Restaurants <- business_search(api_key = key,
location = 'New York',
term = "restaurants",
offset = 0,
limit = 50)
每次我可以获得我想要的所有数据时,通过添加 50 来不断增加偏移量。不过我知道应该有办法写一个循环。
我试过了
restaurant_function <- function(location, term){
business_search(api_key = key,
location = location,
term = term,
offset = offset,
limit = 50)
}
NYC_Restaurants <- for (offset in seq(0,1000,50)) {
restaurant_function('New York','restaurants')
}
它只是返回一个空集。对我做错的任何帮助和理解将不胜感激。谢谢你。
【问题讨论】: