Learn R Programming

rjstat (version 0.4.3)

toJSONstat: 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", ...)

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.

Arguments

x

a data frame or list of data frames

value

name of value column

...

arguments passed on to toJSON

Examples

Run this code
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)

Run the code above in your browser using DataLab