add_token_color: Adds a token color attribute

Description Usage Arguments Examples

View source: R/add_token_color.R

Description

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

Usage

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  # 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))
}

processanimateR documentation built on Nov. 3, 2018, 1:03 a.m.