How do I write a json array from R that has a sequence of lat and long? -
How do I write a json array from R that has a sequence of lat and long? -
how write json array r has sequence of lat , long?
i write:
[[[1,2],[3,4],[5,6]]] the best can is:
tojson(matrix(1:6, ncol = 2, byrow = t)) #"[ [ 1, 2 ],\n[ 3, 4 ],\n[ 5, 6 ] ]" how can wrap thing in array (the json kind)? of import me can write files geojson format linestring.
i utilize fromjson target object :
ll <- fromjson('[[[1,2],[3,4],[5,6]]]') str(ll) list of 1 $ :list of 3 ..$ : num [1:2] 1 2 ..$ : num [1:2] 3 4 ..$ : num [1:2] 5 6 so should create , list of unnamed list, each containing 2 elements:
xx <- list(setnames(split(1:6,rep(1:3,each=2)),null)) identical(tojson(xx),'[[[1,2],[3,4],[5,6]]]') [1] true json r
Comments
Post a Comment