Last active
December 25, 2015 00:19
-
-
Save Protonk/6886551 to your computer and use it in GitHub Desktop.
View R function bodies as JSON Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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