Learn R Programming

pixiedust (version 0.9.4)

sprinkle_bg_pattern: Row and Column Background Striping

Description

Provides background color striping based on row or column. Striping may be done with any number of colors. The most common use of striping is to provide row discrimination in tables.

Usage

sprinkle_bg_pattern(
  x,
  rows = NULL,
  cols = NULL,
  bg_pattern = c("transparent", "#DCDCDC"),
  bg_pattern_by = c("rows", "cols"),
  ...,
  part = c("body", "head", "foot", "interoot", "table")
)

# S3 method for default sprinkle_bg_pattern( x, rows = NULL, cols = NULL, bg_pattern = c("transparent", "#DCDCDC"), bg_pattern_by = c("rows", "cols"), ..., part = c("body", "head", "foot", "interfoot", "table") )

# S3 method for dust_list sprinkle_bg_pattern( x, rows = NULL, cols = NULL, bg_pattern = c("transparent", "#DCDCDC"), bg_pattern_by = c("rows", "cols"), ..., part = c("body", "head", "foot", "interfoot", "table") )

Arguments

x

An object of class dust

rows

Either a numeric vector of rows in the tabular object to be modified or an object of class call. When a call, generated by quote(expression), the expression resolves to a logical vector the same length as the number of rows in the table. Sprinkles are applied to where the expression resolves to TRUE.

cols

Either a numeric vector of columns in the tabular object to be modified, or a character vector of column names. A mixture of character and numeric indices is permissible.

bg_pattern

A character vector giving the colors to be iterated in the pattern.

bg_pattern_by

A subset of c("rows", "cols"), with partial matching accepted. Only the first value is used, and determines the direction of the pattern.

...

Additional arguments to pass to other methods. Currently ignored.

part

A character string denoting which part of the table to modify.

Functional Requirements

  1. Correctly reassigns the appropriate elements bg column in the table part.

  2. Casts an error if x is not a dust object.

  3. Casts an error if bg_pattern is not a character vector.

  4. Casts an error if any element in bg_pattern is not a valid color name.

  5. Casts an error if bg_pattern_by is not a subset of c("rows", "columns") (with partial matching).

  6. Casts an error if part is not one of "body", "head", "foot", or "interfoot"

This is a rare sprinkle that doesn't use the fixed and recycle arguments. They are assumed to be FALSE and "none", respectively, in order to pass through index_to_sprinkle.

See Also

sprinkle_bg, sprinkle, index_to_sprinkle