How to import data from .json file into R?

r

#1

I am fairly new to R, but the more use it, the more I see how powerful it really is over SAS or SPSS. Just one of the major benefits, as I see them, is the ability to get and analyze data from the web.I imagine this will be straight forward in R,currently I am currently want to know is there is a way by which I can read the data of .json format in R.


#2

Hi @harry,

This is a link to a json file:json file

The library jsonlite in R can be used to import the data:

library(jsonlite)
hadley <- fromJSON("https://api.github.com/users/hadley/orgs")

This should give the following dataframe:

Hope this helps!!


#3

Hi
if you read from a file with json then you could use
tipdata<-fromJSON(sprintf("[%s]", paste(readLines(filename), collapse=",")))
This will give you the data frame tipdata in this case.
Alain