Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data frame vars should be treated as containers #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jcheng5
Copy link

@jcheng5 jcheng5 commented Jun 30, 2013

The current behavior for RJSONIO:

> cat(RJSONIO::toJSON(head(cars, 3)))
{
 "speed": [      4,      4,      7 ],
"dist": [      2,     10,      4 ] 
}
> cat(RJSONIO::toJSON(head(cars, 1)))
{
 "speed":      4,
"dist":      2 
}

When nrow(x) == 1, data frame variables are transmitted as scalars. This behavior makes sense for lists, but not for data frames, which are inherently tabular. The Shiny framework makes heavy use of RJSONIO and this behavior has surprised users several times.

With this patch:

> cat(RJSONIO::toJSON(head(cars, 1)))
{
 "speed": [      4 ],
"dist": [      2 ] 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant