0

I'm using package "jsonlite" to get a json file and convert it to a dataframe so i can run some analysis on it. The problem is I am getting very few columns (i.e 12 instead of 100) and it's because the missing columns appeared to be nested. The depth is about 3-4 levels. I have tried to add flatten = TRUE, however no luck.

stats<-fromJSON(paste0("websitehere..api_key=", key, flatten=TRUE))
t<-data.frame(stats)

Link to json im using https://www.dropbox.com/s/hpnaa4phefz6x2f/44844249.json?dl=0

MrLore
  • 3,759
  • 2
  • 28
  • 36
P C
  • 9
  • 2
  • 1
    Welcome to SO. Please read [How to Ask a Good Question](http://stackoverflow.com/help/how-to-ask) We shouldn't have to do more work (like going to a link to get the data) to be able to reproduce your problem. – Rich Scriven Sep 18 '14 at 04:05
  • What exactly do you want the return result to be? What are the 100 columns you expect? The nested nature of this document does not make it clear show you plan to express those relations ships in a data.frame where you can only store columns of atomic vectors. – MrFlick Sep 18 '14 at 04:06
  • 100 is an example but I should have several columns. The result I am looking for is just a dataframe with the proper headers assigned. When I look at the stats, I can see dataframe within dataframes. Ideally I believe each new line of stats should be a variable type. When I turn simple vector=false, I get only 1 observation and like 1k+ columns – P C Sep 18 '14 at 04:20
  • What are the "proper headers". The more specific you can be, the easier it will be to help you. Standard R data.frames do not like to hold other data.frames. There's no "standard" way to turn a row with two nested elements into a single row. What would `list(list(a=1, b=list(b1=1:3, b2=letters[1:3]), c=2, d=list(d1=runif(10), d2=rnorm(10))))` look like, for example. – MrFlick Sep 18 '14 at 05:20
  • you need to at least post the json, or the URI info, in order for anyone to be able to help you here (so that we can work with the json ourselves and advise you what can be done with it) – Peter Verbeet Mar 25 '15 at 16:22

0 Answers0