How to set-up this Python data structure in R -
i have following data structure in python set-up in r. correct way achieve that's akin python set-up.
testing = [ [[12,14], [4]], [[2,1], [5]], [[42,11], [13]] ]
edit 1
based on proposed solution agstudy using following code
library(rjson) json_file <- "/path/jsondata.json" json_data <- fromjson(paste(readlines(json_file), collapse=""))
things worked great. produced following:
list(list(c(12, 14), 4), list(c(2, 1), 5), list(c(42, 11), 13))
what this? nested list type structure?
ll <- list( c( list(c(12,14)),4) , c(list(c(2,1)),5),c(list(c(42,11)),13)) str( ll ) list of 3 $ :list of 2 ..$ : num [1:2] 12 14 ..$ : num 4 $ :list of 2 ..$ : num [1:2] 2 1 ..$ : num 5 $ :list of 2 ..$ : num [1:2] 42 11 ..$ : num 13
access elements through [[
method:
# second list element of first top-level list element ll[[1]][[2]] #[1] 4 # first list element of third top-level list element ll[[3]][[1]] #[1] 42 11
Comments
Post a Comment