This is the development place for R-package voronoiTreemap
- A side event to the annual conference The Use of R in Official Statistics
- https://github.com/uRosConf/unconfUROS2018
- Make it easy to create a plot like this:
knitr::include_graphics("documentation/preisKalei.jpg")
- https://github.com/uRosConf/voronoiTreemap
- important functions:
- vt_input_from_df ... easy data input as a data frame
- vt_export_json ... export to json
- vt_d3 ... create an htmlwidget
- vt_app ... start a shiny to create a Voronoi treemap
library(voronoiTreemap)
data(ExampleGDP)
knitr::kable(head(ExampleGDP,3))
h1 | h2 | h3 | color | weight | codes |
---|---|---|---|---|---|
Total | Asia | China | #f58321 | 14.84 | CN |
Total | Asia | Japan | #f58321 | 5.91 | JP |
Total | Asia | India | #f58321 | 2.83 | IN |
gdp_json <- vt_export_json(vt_input_from_df(ExampleGDP))
vt_d3(gdp_json)
vt_d3(gdp_json,label = FALSE, color_border = "#000000", size_border = "2px", legend = TRUE)
- You can set a seed (in Javascript)!
vt_d3(gdp_json, legend = TRUE, legend_title = "Continents", seed = 1)
- Colors can be provided for each cell independently.
data(canada)
canada <- canada[canada$h1=="Canada",]
canada$codes <- canada$h3
canadaH <- vt_export_json(vt_input_from_df(canada,scaleToPerc = FALSE))
vt_d3(canadaH, label=FALSE,width = 400,height = 400)
- Colors could be computed according to a numeric variable, e.g. with the scales package.
canada$color <- scales::seq_gradient_pal(low = "#999999",high = "#ffffff")(canada$weight/max(canada$weight))
canadaH <- vt_export_json(vt_input_from_df(canada,scaleToPerc = FALSE))
vt_d3(canadaH, label=FALSE,width = 400,height = 400, color_border = "#000000")
knitr::include_graphics("documentation/shiny1.jpg")
knitr::include_graphics("documentation/shiny2.jpg")