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

add_token_size(eventlog, attribute, size_attribute, min.size = 2,
  max.size = 8, na.size = 2, size_mapping = size_numeric(eventlog
  %>% pull(`!!`(attr)), min.size, max.size, na.size))

Arguments

eventlog

The source eventlog

attribute

The source attribute to calculate the size on

size_attribute

The target attribute to store the size information in

min.size

The minimum size

max.size

The maximum size

na.size

The size for NA values

size_mapping

A function that takes the attribute and returns a size between min.size and max.size, the default is a linear transformation that only works for numeric attributes..

Examples

{ # Load example event log library(eventdataR) # Generate random numeric attribute patients$test <- rnorm(nrow(patients), 5) # Add token size based on a numeric attribute add_token_size(patients, "test", "size") }
#> Warning: The scale mechanism is being replaced with D3 scales. This method is going to be removed soon.
#> Event log consisting of: #> 5442 events #> 7 traces #> 500 cases #> 7 activities #> 2721 activity instances #> #> # A tibble: 5,442 x 9 #> handling patient employee handling_id registration_ty~ time #> <fct> <chr> <fct> <chr> <fct> <dttm> #> 1 Registr~ 1 r1 1 start 2017-01-02 11:41:53 #> 2 Registr~ 2 r1 2 start 2017-01-02 11:41:53 #> 3 Registr~ 3 r1 3 start 2017-01-04 01:34:05 #> 4 Registr~ 4 r1 4 start 2017-01-04 01:34:04 #> 5 Registr~ 5 r1 5 start 2017-01-04 16:07:47 #> 6 Registr~ 6 r1 6 start 2017-01-04 16:07:47 #> 7 Registr~ 7 r1 7 start 2017-01-05 04:56:11 #> 8 Registr~ 8 r1 8 start 2017-01-05 04:56:11 #> 9 Registr~ 9 r1 9 start 2017-01-06 05:58:54 #> 10 Registr~ 10 r1 10 start 2017-01-06 05:58:54 #> # ... with 5,432 more rows, and 3 more variables: .order <int>, test <dbl>, #> # size <dbl>