Re: [R] reading json tables

2012-12-02 Thread Duncan Temple Lang
Hi Michael > The actual result I want is two data frames, wheat and monarch, whereas > fromJSON returns a list of lists. I'll try to > figure that part out. do.call(rbind, data[[1]]) will do the job, but there are elements in each of data[[1]] and data[[2]] that are incomplete and which need

Re: [R] reading json tables

2012-12-02 Thread Michael Friendly
On 12/1/2012 4:08 PM, Duncan Temple Lang wrote: Hi Michael The problem is that the content of the .js file is not JSON, but actual JavaScript code. You could use something like the following tt = readLines("http://mbostock.github.com/protovis/ex/wheat.js";) txt = c("[", gsub(";", ",", gsub

Re: [R] reading json tables

2012-12-01 Thread Duncan Temple Lang
Hi Michael The problem is that the content of the .js file is not JSON, but actual JavaScript code. You could use something like the following tt = readLines("http://mbostock.github.com/protovis/ex/wheat.js";) txt = c("[", gsub(";", ",", gsub("var [a-zA-Z]+ = ", "", tt)), "]") tmp = paste(tx

[R] reading json tables

2012-12-01 Thread Michael Friendly
I'm trying to read two data sets in json format from a single .js file. I've tried fromJSON() in both RJSONIOIO and RJSON packages, but they require that the lines be pre-parsed somehow in ways I don't understand. Can someone help? > wheat <- readLines("http://mbostock.github.com/protovis/ex/wh