library(ggplot2)
library(tabplot)
library(RJSONIO)
data(diamonds)
# adjustment of tableplot object, to be implemented in tabplot itself
adjust <- function(tp){
atp <- list()
varnms <- sapply(tp$columns, function(i) i$name)
vars <- lapply( tp$columns
, function(i) { if (i$isnumeric)
return(list( mean = i$mean
, compl = i$compl/100
)
)
categories <- colnames(i$freq)
freq <- round(i$freq / rowSums(i$freq), 4)
colnames(freq) <- NULL
list( freq = freq, palet=i$palet, categories=categories)
}
)
names(vars) <- varnms
atp$vars <- vars
atp
}
tp <- tableplot(diamonds[c("carat", "price", "cut")], plot=FALSE)
atp <- adjust(tp)
writeLines(toJSON(atp), con="diamonds.json")
toJSON
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.