Pageviews

Saturday 2 May 2015

Reading and Parsing JSON Data in R

by Unknown  |  in R at  Saturday, May 02, 2015

R is a wonderful statistical language with a lot of features.R can read and parse a large number of data formats including .xls,.txt,.json etc.

JSON stands for Java Script Object Notation.For reading and parsing json data in R consists of following steps:

1.Grabbing Data:

Our first step includes how we grab the data.The data can be on a Server,html link or stored in a database.In my case the data is stored on a Server,which i was given access via SSH.






                                       

Here I have 11 Gb of tweets which i need to download.I had used the jsonlite package in R to get the data from server.The feature I liked the most is the streaming part.You can give the number of lines you want to read in one iteration.


Here I had used jsonlite package and i opted to read 10000 lines in one run.This is the process of reading json data in R.

2.Extracting Data from JSON file

Now we have loaded our data in R,now it is the time to extract our data from the file.With the following code we can extract data from json file.We need to use [['  ']] (double braces) to get our data.




After getting data,i converted the data to a data frame.After then we can apply text mining,social media analytics on it.





0 comments:

Proudly Powered by Blogger.