### Install rjstat Package Source: https://github.com/ajschumacher/rjstat/blob/master/README.md Installs the rjstat package from CRAN or the development version from GitHub. ```r install.packages('rjstat') ``` ```r library(devtools) install_github("ajschumacher/rjstat") ``` -------------------------------- ### Convert JSON-stat to R and Back Source: https://github.com/ajschumacher/rjstat/blob/master/README.md Demonstrates converting JSON-stat data to R data frames and then back to JSON-stat, highlighting compatibility. ```r library(rjstat) # Assuming irisJSONstat is already created from the previous example # irisJSONstat <- toJSONstat(list(iris=irises)) head(fromJSONstat(irisJSONstat)[[1]]) ``` -------------------------------- ### Read JSON-stat Data Source: https://github.com/ajschumacher/rjstat/blob/master/README.md Reads data from a JSON-stat formatted URL into a list of R data frames. Supports reading by labels or IDs. ```r library(rjstat) oecd.canada.url <- "https://json-stat.org/samples/oecd-canada.json" # Read from JSON-stat to a list of data frames: results <- fromJSONstat(readLines(oecd.canada.url)) names(results) # Read using IDs rather than labels: results <- fromJSONstat(readLines(oecd.canada.url), naming="id") names(results) ``` -------------------------------- ### Convert R Data to JSON-stat Source: https://github.com/ajschumacher/rjstat/blob/master/README.md Converts a list of R data frames into a JSON-stat formatted string. Requires data frames to have exactly one value column. ```r library(rjstat) library(reshape) irises <- melt(cbind(iris, Specimen=rep(1:50, 3)), id.vars=c("Species", "Specimen")) irisJSONstat <- toJSONstat(list(iris=irises)) cat(substr(irisJSONstat, 1, 76)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.