R-将Google Places API数据放入数据帧中



我已经使用Google Places API提取了我所在地区的所有餐厅,但我现在很难将这些餐厅放入数据框架中(我的最终目标是将其导出到excel(。

我有以下代码:

myPlaces <- google_places(location = myLocation, 
place_type = "restaurant",
radius = 500,
key = key)
nextPlaces <- google_places(location = myLocation,
radius = 500,
place_type = "restaurant",
page_token = myPlaces$next_page_token, 
key = key)
nextPlaces2 <- google_places(location = myLocation,
radius = 500,
place_type = "restaurant",
page_token = nextPlaces$next_page_token, 
key = key)

这给了我想要的数据,但当我尝试用它创建数据帧时,我失败了:

> df1 <- select(myPlaces, name, business_status, rating, types, price_level, geometry.location.lat, geometry.location.lng)

得到错误消息";错误:select()不处理列表">

我是R的新手,花了我很多小时才达到这一点,我觉得我已经接近我的最终目标,但被这件事难住了。非常感谢你的帮助。

谢谢,

您可以编写:

myPlaces<- myPlaces$results
nextPlaces<- nextPlaces$results
nextPlaces2<- nextPlaces2$results

最新更新