-
Notifications
You must be signed in to change notification settings - Fork 13
/
README.Rmd
100 lines (79 loc) · 3.18 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
library(voronoiTreemap)
```
![Build Status](https://travis-ci.org/uRosConf/voronoiTreemap.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/uRosConf/voronoiTreemap/badge.svg?branch=master)](https://coveralls.io/github/uRosConf/voronoiTreemap?branch=master)
[![CRAN](http://www.r-pkg.org/badges/version/voronoiTreemap)](https://CRAN.R-project.org/package=voronoiTreemap)
[![Downloads](http://cranlogs.r-pkg.org/badges/voronoiTreemap)](https://CRAN.R-project.org/package=voronoiTreemap)
<!--[![Mentioned in Awesome Official Statistics ](https://awesome.re/mentioned-badge.svg)](http://www.awesomeofficialstatistics.org)-->
# voronoiTreemap
This is the development place for R-package voronoiTreemap
##Created at unconfUROS2018
- A side event to the annual conference [The Use of R in Official Statistics](http://r-project.ro/conference2019.html)
- [https://github.com/uRosConf/unconfUROS2018](https://github.com/uRosConf/unconfUROS2018)
## Idea
- Make it easy to create a plot like this:
```{r, out.width = "800px"}
knitr::include_graphics("documentation/preisKalei.jpg")
```
## R package
- [https://github.com/uRosConf/voronoiTreemap](https://github.com/uros2018/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
```{r, echo = TRUE}
library(voronoiTreemap)
data(ExampleGDP)
knitr::kable(head(ExampleGDP,3))
```
## Create a first graph
```{r, echo = TRUE,}
gdp_json <- vt_export_json(vt_input_from_df(ExampleGDP))
vt_d3(gdp_json)
```
## There a couple of settings you can change I
```{r, echo = TRUE}
vt_d3(gdp_json,label = FALSE, color_border = "#000000", size_border = "2px", legend = TRUE)
```
## There a couple of settings you can change II
- You can set a seed (in Javascript)!
```{r, echo = TRUE}
vt_d3(gdp_json, legend = TRUE, legend_title = "Continents", seed = 1)
```
## A 2nd Example (Canadian Consumer Price Index) I
- Colors can be provided for each cell independently.
```{r, echo = TRUE}
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)
```
## A 2nd Example (Canadian Consumer Price Index) II
- Colors could be computed according to a numeric variable, e.g. with the *scales* package.
```{r, echo = TRUE}
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")
```
## Shiny App I
```{r, out.width = "800px"}
knitr::include_graphics("documentation/shiny1.jpg")
```
## Shiny App II
```{r, out.width = "800px"}
knitr::include_graphics("documentation/shiny2.jpg")
```