Learn R Programming

rnrfa (version 0.3.0)

ToJSONarray: Transforms a data.frame into a JSON array in a format compatible with D3.js and Protovis (source by: http://theweiluo.wordpress.com/2011/09/30/r-to-json-for-d3-js-and-protovis/)

Description

This function transforms a R data frame into a JSON array such that each row in R becomes an JSON object in the array.

Usage

ToJSONarray(dtf)

Arguments

dtf
this is a data.frame

Value

  • JSON array in a format compatible with D3.js and Protovis

Details

The rjson/RJSONIO packages convert a data frame into a JSON hashmap, in which each column of the data frame becomes a named array.

Examples

Run this code
# ToJSONarray(dtf)

Run the code above in your browser using DataLab