cascade: Combine cascading elements

Description Usage Arguments Examples

View source: R/cascading-theme.R

Description

Combines two values. For most values, child is returned in place of parent. Exeptions are formulas (converted to quosures and evaluated with the object parent and objects from the CascadingTheme's data field available), functions (evaluated on the parent if there is one), and cascading_element()s (values are merged recursively). Use rlang::as_box() to cascade items without applying any class-based rules, and rlang::zap() to remove a key from the parent cascading_element().

Usage

 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
cascade(parent, child = missing_value(), cascading_theme = NULL)

## Default S3 method:
cascade(parent, child = missing_value(), cascading_theme = NULL)

## S3 method for class ''function''
cascade(parent, child = missing_value(), cascading_theme = NULL)

## S3 method for class 'quosure'
cascade(parent, child = missing_value(), cascading_theme = NULL)

## S3 method for class 'formula'
cascade(parent, child = missing_value(), cascading_theme = NULL)

reverse_cascade(child, parent = missing_value(), cascading_theme = NULL)

## Default S3 method:
reverse_cascade(child, parent = missing_value(), cascading_theme = NULL)

## S3 method for class ''function''
reverse_cascade(child, parent = missing_value(), cascading_theme = NULL)

## S3 method for class 'quosure'
reverse_cascade(child, parent = missing_value(), cascading_theme = NULL)

## S3 method for class 'formula'
reverse_cascade(child, parent = missing_value(), cascading_theme = NULL)

## S3 method for class 'cascading_element'
reverse_cascade(child, parent = missing_value(), cascading_theme = NULL)

Arguments

parent

The value to be inherited from

child

The value to inherit

cascading_theme

The CascadingTheme object from which cascade() is called.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# in most cases, child is returned in place parent
cascade("parent value", "child value")

# formulas/quosures can use `parent` (tidy evaluation is supported)
# and data supplied by the theme
cascade(
  "parent value",
  ~paste(parent, "child value", sep = separator),
  CascadingTheme$new(data = list(separator = "=>"))
)

# items of cascading elements are merged recursively using the
# same rules
cascade(
  cascading_element(key1 = "parent value 1", key2 = "parent_value 2"),
  cascading_element(
    key1 = "child value 1",
    key2 = ~paste(parent, "child value2", sep = separator)
  ),
  CascadingTheme$new(data = list(separator = "=>"))
)

paleolimbot/ggr6 documentation built on Feb. 5, 2020, 2:17 p.m.