'R - Putting Google Places API data into a dataframe

I've managed to extract all restaurants in my local area using Google Places API, i am struggling now however to get these into a dataframe (my ultimate aim being to then export this to excel).

I have the following code:

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)

This is getting me the data i want but when i try and create a data frame with it i fail with:

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

getting the error message "Error: select() doesn't handle lists."

I'm fairly new to R and its taken me many hours to this point, i feel like i'm close to my end goal but stumped by this. Ever so grateful for any help.

Thanks,



Solution 1:[1]

You can write:

myPlaces<- myPlaces$results

nextPlaces<- nextPlaces$results

nextPlaces2<- nextPlaces2$results

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cholo.trem