-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessAnimateR_vignette.R
37 lines (27 loc) · 1.21 KB
/
ProcessAnimateR_vignette.R
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
# Libraries ---------------------------------------------------------------
library(dplyr) ##pipes
library(tidyr) ##tidy data
library(lubridate) ##date time
library(bupaR) ##buisness process analytics
library(processanimateR) ##animates process
# Create performance time flags ------------------------------------------------
my_flags <- data.frame(value = c(0,2,4,8,16)) %>%
mutate(day = days(value))
# Create timestamps of flags ----------------------------------------------
my_timeflags <- patients %>%
cases %>%
crossing(my_flags) %>%
mutate(time = start_timestamp + day) %>%
filter(time <= complete_timestamp) %>%
select("case" = patient,time,value) ##must be case, time, value
# Animate process ---------------------------------------------------------
patients %>%
animate_process(mode ="absolute",
jitter=10,
legend = "color",
mapping = token_aes(
color = token_scale(my_timeflags
, scale = "ordinal"
, domain = my_flags$value
, range = rev(RColorBrewer::brewer.pal(5,"Spectral"))
)))