Skip to content

Instantly share code, notes, and snippets.

@Protonk
Last active December 25, 2015 00:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Protonk/6886551 to your computer and use it in GitHub Desktop.
Save Protonk/6886551 to your computer and use it in GitHub Desktop.
View R function bodies as JSON Objects
## Once you've loaded the dependencies you don't have to load them again in a session
## May have to install them via `install.packages(c('RJSONIO', 'plyr'))` first and only once per device
# Uses C parser for faster results compared to rjson
require('RJSONIO')
# Get a quick non-trivial function example
require('plyr')
# body(x) extracts the function body for x (also could set the function body of x)
ddBody <- as.list(body(ddply))
# Print the results. Could also stream them over a shiny server to a browser.
cat(toJSON(ddBody))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment