read json into R -


after couple of days struggle, decided ask experts of stackoverflow.

i wanted export (for example) "http://www.appannie.com/app/ios/instagram/ranking/history/chart_data/?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone" r.

so here's tried.

library(rjsonio) library(rjson) library(rcurl) appannie <- geturl("http://www.appannie.com/app/ios/instagram/ranking/history/chart_data/.json?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone") fromjson(appannie) 

but gives me error of "no data parse".

but can see there data (i can see data browser).

[{"data": [[1286323200000, 70, "initial release\n"], [1286409600000, 65, null], [1286496000000, 89, null], [1286582400000, 106, null], [1286668800000, 143, null], [1286755200000, 172, null], [1286841600000, 106, null], [1286928000000, 116, null], [1287014400000, 78, null], [1287100800000, 102, null], ...... [1338768000000, 2, null]], "label": "photo , video"}]

so tried one.

fromjson(paste(readlines('http://www.appannie.com/app/ios/instagram/ranking/history/chart_data/.json?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone'), collapse=""))  

but 1 gives me error of "unexpected character '<'".

can give me guidance why happening , how solve this?

given data pasted:

  jsonraw <- '{"data": [[1286323200000, 70, "initial release\n"], [1286409600000, 65, null], [1286496000000, 89, null], [1286582400000, 106, null], [1286668800000, 143, null], [1286755200000, 172, null], [1286841600000, 106, null], [1286928000000, 116, null], [1287014400000, 78, null], [1287100800000, 102, null], [1338768000000, 2, null]], "label": "photo , video"}]' 

everything works fine:

  jsonparsed <- fromjson(jsonraw) 

what happening r not have access website. take @ output rcurl statement. if not json-like data, there have issue.

edit:

you state

"but can see there data (i can see data browser)."

but logged in, not same thing seeing in r


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -