toJSONstat: Convert data frame(s) to JSON-stat format

View source: R/rjstat.R

toJSONstatR Documentation

Convert data frame(s) to JSON-stat format

Description

This function takes a data frame or list of data frames and returns a string representation in JSON-stat format. The input data frame(s) must be in maximally long tidy format: with only one value column and all other columns representing dimensions.

Usage

toJSONstat(x, value = "value", ...)

Arguments

x

a data frame or list of data frames

value

name of value column

...

arguments passed on to toJSON

Value

For a data frame: A JSON-stat format response with class dataset. For a list of data frames: A JSON-stat format response with class collection.

Examples

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))

# Add indentation whitespace
toJSONstat(as.data.frame(Titanic), value = "Freq", pretty = TRUE)

rjstat documentation built on Sept. 8, 2023, 5:10 p.m.