Extract Data from Yelp API

less than 1 minute read

R code for acquiring data

library(jsonlite)
yelp <- fromJSON("https://www.dropbox.com/s/gd1k41y9gbpfwq3/yelp_academic_dataset_business.json")

jsonlite actually has a function to deal with this NDJSON file type with stream_in() function

Use file() function to create a “connection” for accessing to the files on your disk when you use stream_in() function.

53MB JSON data upload to R Studio. To import, add “ marks References

library(jsonlite)
yelp <- stream_in(file("yelp_academic_dataset_business.json"))
head(yelp,10)

Find out how data has been imported run str() function.

str(yelp)

To see the data frame in RStudio, use as_data_frame() function from the tibble package

library(tibble)
yelp_tbl <- as_data_frame(yelp_flat)
yelp_tbl