-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathaugment.Rmd
113 lines (85 loc) · 3.14 KB
/
augment.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
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: "bupaR Docs | Augment logs"
---
```{r echo = F, out.width="25%", fig.align = "right"}
knitr::include_graphics("images/icons/enrich.png")
```
***
# Augment logs
```{r eval = F}
library(bupaverse)
library(dplyr)
```
```{r include = F}
library(bupaverse)
library(dplyr)
```
Enriching an event log with calculated metrics can be done using `augment()`. For example, consider [`trace_length()`](control_flow_analysis.html).
```{r}
traffic_fines %>%
trace_length(level = "case")
```
Feeding the resulting table back to `traffic_fines` with `augment()` makes the trace length metric available as a case attribute for further analysis.
```{r}
traffic_fines %>%
trace_length(level = "case") %>%
augment(traffic_fines) %>%
glimpse()
```
## Adjust names
Using the `prefix` argument, you can add a descriptive prefix to the name of the new variable. In the current example, where the variable is called _absolute_, it might be useful to add the prefix _trace_length_.
```{r}
traffic_fines %>%
trace_length(level = "case") %>%
augment(traffic_fines, prefix = "trace_length") %>%
glimpse()
```
## Select variables
Some metrics return several variables with information. Say you want to add information on the _processing time_ of each _activity_ to the data.
```{r}
patients %>%
processing_time(level = "activity", units = "hours")
```
Calling `augment` without any further arguments will add all columns, from _min_ until _relative_frequency_ to the data.
```{r}
patients %>%
processing_time(level = "activity", units = "hours") %>%
augment(patients) %>%
glimpse()
```
Using the `columns` argument we can specify a selection of columns that we want to use for augmenting the log. For example, say we are only interested in the _mean_ and _median_ processing time. Let's also add a descriptive prefix to these columns.
```{r}
patients %>%
processing_time(level = "activity", units = "hours") %>%
augment(patients, columns = c("mean","median"), prefix = "processing_time") %>%
glimpse()
```
## Adding multiple metrics
When you want to add multiple metrics, it is imperative to save intermediate updates of the data. Consider the example below.
```{r}
patients %>%
trace_length(level = "case") %>%
augment(patients, prefix = "trace_length") %>%
trace_coverage(level = "case") %>%
augment(patients, prefix = "trace_frequency") %>%
glimpse()
```
As you can see only the [`trace_coverage()`](control_flow_analysis.html) values of the second augment are added, while the first augment is lost. This is because the `patients` data set did not get updated after the first `augment()` call. The proper way would be as follows.
```{r}
patients %>%
trace_length(level = "case") %>%
augment(patients, prefix = "trace_length") -> patients
patients %>%
trace_coverage(level = "case") %>%
augment(patients, prefix = "trace_frequency") %>%
glimpse()
```
```{r include = F}
patients <- eventdataR::patients
```
```{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')
```