Adds a color attribute to an event log that can be used in combination with the token_color parameter of animate_process

add_token_color(eventlog, attribute, color_attribute, palette = "YlOrBr",
  na.color = "red", color_mapping = scales::col_numeric(palette, eventlog
  %>% pull(`!!`(attr)), na.color = na.color))

Arguments

eventlog

The source eventlog

attribute

The source attribute to calculate the color on

color_attribute

The target attribute to store the color information in

palette

The palette to use with the default color mapping

na.color

The color for NA values

color_mapping

A function that takes the attribute and returns a color, the default is using scales::col_numeric.

Examples

{ # Load example event log library(eventdataR) # Add token color based on a numeric attribute add_token_color(patients, "time", "color") # Add token color based on a factor attribute add_token_color(patients, "employee", "color", color_mapping = scales::col_factor("Set3", patients$employee)) }
#> Event log consisting of: #> 5442 events #> 7 traces #> 500 cases #> 7 activities #> 2721 activity instances #> #> # A tibble: 5,442 x 8 #> handling patient employee handling_id registration_ty~ time #> <fct> <chr> <fct> <chr> <fct> <dttm> #> 1 Registrat~ 1 r1 1 start 2017-01-02 11:41:53 #> 2 Registrat~ 2 r1 2 start 2017-01-02 11:41:53 #> 3 Registrat~ 3 r1 3 start 2017-01-04 01:34:05 #> 4 Registrat~ 4 r1 4 start 2017-01-04 01:34:04 #> 5 Registrat~ 5 r1 5 start 2017-01-04 16:07:47 #> 6 Registrat~ 6 r1 6 start 2017-01-04 16:07:47 #> 7 Registrat~ 7 r1 7 start 2017-01-05 04:56:11 #> 8 Registrat~ 8 r1 8 start 2017-01-05 04:56:11 #> 9 Registrat~ 9 r1 9 start 2017-01-06 05:58:54 #> 10 Registrat~ 10 r1 10 start 2017-01-06 05:58:54 #> # ... with 5,432 more rows, and 2 more variables: .order <int>, color <chr>