Description Usage Arguments Author(s) References Examples
Creates a json file from an input
1 |
df |
a data.frame to be converted |
mode |
there are four modes "vector", "coords" , "rowToObject", "hierarchy" |
Simon Raper
I got the code for the recursive function that makes the json hierarchy from someone on stack overflow. I'm sorry I was going to credit them but can no loner find the post. Let me know if it's you!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | data(iris)
jsonOut<-dfToJSON(iris)
fileConn<-file("iris.json")
writeLines(jsonOut, fileConn)
close(fileConn)
jsonOut<-dfToJSON(iris, mode="rowToObject")
fileConn<-file("irisRows.json")
writeLines(jsonOut, fileConn)
close(fileConn)
jsonOut<-dfToJSON(iris, mode="coords")
fileConn<-file("irisCoords.json")
writeLines(jsonOut, fileConn)
close(fileConn)
tree<-dcast(data=iris, Species+Petal.Width ~ .)
jsonOut<-dfToJSON(iris, mode="hierarchy")
fileConn<-file("irisTree.json")
writeLines(jsonOut, fileConn)
close(fileConn)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.