Hi,
I have a very rudimentary kind of question on using unlist(). I am
parsing a bunch of JSON text using rjson package. Some data elements in
a dictionary happen to be null which rjson parses correctly.
> fromJSON(json_str='{"query":{"A":10, "B":null, "C":"hello"},
"query":{"A":20, "B":null, "C":"hello again"}}')
$query
$query$A
[1] 10
$query$B
NULL
$query$C
[1] "hello"
$query
$query$A
[1] 20
$query$B
NULL
$query$C
[1] "hello again"
I need to view this as a matrix, for example as
matrix(unlist(fromJSON(json_str='{"query":{"A":10, "B":null,
"C":"hello"}, "query":{"A":20, "B":null, "C":"hello again"}}')), nr=2)
BUT I lose column "B". It gets worse if some of the B's are not null,
and if I were really unlucky then matrix() would not fail but data will
be messed up.
My question is - is there a different way of using unlist() that I am
missing? Is there a better way of getting this data in a rectangular format?
--
Thanks and regards,
Dinesh
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.