data.frame.to.json {AnalysisPageServer} | R Documentation

## data.frame.to.json

### Description

Create a JSON representation of a data.frame

### Usage

    data.frame.to.json(df)

### Arguments

`df` | data.frame to represent as a JSON

### Details

We represent a data.frame as an hash of hashes. Factors are first coerced into characters.

The outer hash is keyed by the rownames of your data.frame The inner hash is keyed by the colnames of your data.frame

### Value

JSON string

### Author(s)

Brad Friedman

### Examples

    df <- data.frame(A=1:3, B=3:1, C=factor(c("foo","bar","foo")), row.names = c("one", "two", "three"))
    ## Should give the following
    ## {"one":{"A":1,"B":3,"C":"foo"},"two":{"A":2,"B":2,"C":"bar"},"three":{"A":3,"B":1,"C":"foo"}}
    data.frame.to.json(df)

[Package AnalysisPageServer version 1.20.0 Index]