-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathadvanced_maps.Rmd
88 lines (61 loc) · 2.75 KB
/
advanced_maps.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
---
title: "bupaR Docs | Advanced Maps"
---
```{r echo = F, out.width="25%", fig.align = "right"}
knitr::include_graphics("images/icons/pm.PNG")
```
***
# Advanced maps
```{r include = F}
library(bupaverse)
knitr::opts_chunk$set(fig.height=3)
```
```{r eval = F}
library(bupaverse)
```
## Combining different profiles
The profile used for nodes and edges can be differentiated using the `type_nodes` and `type_edges` attributes instead of the `type` argument. In this way, information about frequencies and performance, or any other value, can be combined in the same graph.
```{r fig.height=2}
patients %>%
process_map(type_nodes = frequency("relative_case"),
type_edges = performance(mean))
```
## Adding secondary information
You can add a second layer of information to both nodes and edges.
```{r}
patients %>%
process_map(type = frequency("relative_case"),
sec = frequency("absolute"))
```
Both primary and secondary layers can be differentiated between nodes and edges.
```{r warning = F}
patients %>%
process_map(type_nodes = frequency("relative_case"),
type_edges = performance(units = "hours"),
sec_nodes = frequency("absolute"),
sec_edges = performance(FUN = max, units = "hours"))
```
## Customizing colors
Both `frequency()` and `performance()` have the argument `color_scale` and `color_edges` to customize the colors in the process map:
* `color_scale`: set the color scale to fill the nodes. Can be any of the scales in `RColorBrewer::brewer.pal.info`. Defaults to _PuBu_ (frequency) or _Reds_ (performance)
* `color_edges`: any single color to apply to the arrows. Can be a named color, hex-code, or a result of `rgb`. Defaults to _dodgerblue4_ (frequency) or _red4_ (performance)
Configuring the colors can be useful to harmonize the process map aesthetics when using differing layers for nodes and edges.
```{r fig.height=2}
patients %>%
process_map(type_nodes = frequency("relative_case", color_scale = "PuBu"),
type_edges = performance(mean, color_edges = "dodgerblue4"))
```
## Customizing the layout
The layout of the process map can be further customized:
* Instead of a left-right (LR) layout, the `rankdir` can be set to TB (top-bottom), BT (bottom-top) or RL (right-left).
* The varying edge width can be disabled.
* If `render` is set to `FALSE`, the function will return an unrendered graph, which can be further modified. See [here](http://rich-iannone.github.io/DiagrammeR/) for more information.
```{r include = F}
traffic_fines <- eventdataR::traffic_fines
```
```{r footer, results = "asis", echo = F}
CURRENT_PAGE <- stringr::str_replace(knitr::current_input(), ".Rmd",".html")
res <- knitr::knit_expand("_button_footer.Rmd", quiet = TRUE)
res <- knitr::knit_child(text = unlist(res), quiet = TRUE)
cat(res, sep = '\n')
```