title: Converting JSON file to data.frame in R
body: <p>I have a file which contain event data(click data of users interaction with app) in JSON format, I need to convert it in data frame. I used this:</p>
  
  <pre><code>require(RJSONIO)
  result &lt;- fromJSON('events_data.json',nullValue = NA)
  result &lt;- do.call(rbind,lapply(result,data.frame,stringsAsFactors=FALSE))
  </code></pre>
  
  <p>which generates this result</p>
  
  <pre><code>summary(result)
                    Length Class  Mode     
  _id               1      -none- character
  session           2      -none- list     
  metrics           0      -none- list     
  arrival_timestamp 1      -none- character
  event_type        1      -none- character
  event_timestamp   1      -none- character
  event_version     1      -none- character
  application       7      -none- list     
  client            2      -none- character
  device            4      -none- list     
  attributes        3      -none- character
  </code></pre>
  
  <p>When I am trying to convert this list of list into data frame I get an error</p>
  
  <pre><code>Error in data.frame(locale = c("US", "en_US", "en"), platform = c("5.1.1",  : 
    arguments imply differing number of rows: 3, 2, 1
  </code></pre>
  
  <p>Here is the data file, <a href="https://www.dropbox.com/s/put3ma0c49c2bq2/events_data.json?dl=0" rel="nofollow noreferrer">click here</a>(Just for reference). Can someone help me out. JSON file contain</p>
  
  <pre><code>{"_id":{"$oid":"57a30ce268fd0809ec4d194f"},"session":{"start_timestamp":{"$numberLong":"1470183490481"},"session_id":"def5faa9-20160803-001810481"},"metrics":{},"arrival_timestamp":{"$numberLong":"1470183523054"},"event_type":"OfferViewed","event_timestamp":{"$numberLong":"1470183505399"},"event_version":"3.0","application":{"package_name":"com.think.vito","title":"Vito","version_code":"5","app_id":"7ffa58dab3c646cea642e961ff8a8070","cognito_identity_pool_id":"us-east-1:4d9cf803-0487-44ec-be27-1e160d15df74","version_name":"2.0.0.0","sdk":{"version":"2.2.2","name":"aws-sdk-android"}},"client":{"cognito_id":"us-east-1:2e26918b-f7b1-471e-9df4-b931509f7d37","client_id":"ee0b61b0-85cf-4b2f-960e-e2aedef5faa9"},"device":{"locale":{"country":"US","code":"en_US","language":"en"},"platform":{"version":"5.1.1","name":"ANDROID"},"make":"YU","model":"AO5510"},"attributes":{"Category":"120000","CustomerID":"4078","OfferID":"45436"}}
  {"_id":{"$oid":"57a30ce268fd0809ec4d1950"},"session":{"start_timestamp":{"$numberLong":"1470183490481"},"session_id":"def5faa9-20160803-001810481"},"metrics":{},"arrival_timestamp":{"$numberLong":"1470183523054"},"event_type":"ContextMenuItemSelected","event_timestamp":{"$numberLong":"1470183500206"},"event_version":"3.0","application":{"package_name":"com.think.vito","title":"Vito","version_code":"5","app_id":"7ffa58dab3c646cea642e961ff8a8070","cognito_identity_pool_id":"us-east-1:4d9cf803-0487-44ec-be27-1e160d15df74","version_name":"2.0.0.0","sdk":{"version":"2.2.2","name":"aws-sdk-android"}},"client":{"cognito_id":"us-east-1:2e26918b-f7b1-471e-9df4-b931509f7d37","client_id":"ee0b61b0-85cf-4b2f-960e-e2aedef5faa9"},"device":{"locale":{"country":"US","code":"en_US","language":"en"},"platform":{"version":"5.1.1","name":"ANDROID"},"make":"YU","model":"AO5510"},"attributes":{"MenuItem":"OfferList","CustomerID":"4078"}}
  </code></pre>