I have a very messy JSON file (lists inside of lists) that I'm trying to convert to an R dataframe (part of the reason to convert the file is that I need to export it into a .csv file). Here is a sample of the data (https://www.dropbox.com/s/ikb4znhpaavyc9z/20140909-20141010_10zdfxhqf0_2014_10_09_23_50_activities.json?dl=0). I tried this solution (Parse nested JSON to Data Frame in R), but that got rid of many of my columns. Below is the code I have so far:
library("twitteR")
library ("streamR")
library("rjson")
json_file <- "20140909-20141010_10zdfxhqf0_2014_09_09_01_00_activities.json"
json_data <- fromJSON(file=json_file) #convert to r list
str (json_data) #list of 16 objects
#unlist elements
tweets.i <- lapply(json_data, function(x){ unlist(x)})
tweets <- do.call("rbind", tweets.i)
tweets <- as.data.frame(tweets)
library(plyr)
tweets <- rbind.fill(lapply(tweets.i,
function(x) do.call("data.frame", as.list(x))
))
Anyone have a way to convert the file to an R dataframe without losing all the info? I'm open to using Python to do this work to, I just don't have the expertise to figure out how to code it.