alter_at {grobblR} | R Documentation |
Alter aesthetics / structures at certain areas of a grob matrix
Description
Flexibly alter the aesthetic / structure of a grob matrix object at specific points of the data.frame/matrix.
Usage
alter_at(
grob_object,
.f = NULL,
...,
columns = NULL,
rows = NULL,
data = NULL,
structure = NULL,
aesthetic = NULL,
group = NULL
)
Arguments
grob_object |
The R6 grob object class initialized by |
.f |
A quosure style lambda |
... |
Logical predicates defined in terms of the variables in the initial
data frame / matrix, or if the user provides a new data.frame to evaluate via
If no logical predicates provided, then the entire columns will be altered. |
columns |
A character vector of column names, or numeric column indices,
of the initial data.frame/matrix, or |
rows |
A numeric vector of row indices, of the initial data.frame/matrix,
or Ignored if the user is altering a structure and not an aesthetic. |
data |
A separate data.frame/matrix of the same dimensions as the initial
data.frame/matrix which the Must match the dimensions of the subset of the initial data.frame/matrix the user is attempting to alter. Ignored if the user is altering a structure and not an aesthetic. |
structure |
Which structure the user wants to make alterations to. If left
View the documentation of |
aesthetic |
Which aesthetic the user wants to make alterations to. If left
View the documentation of |
group |
Which group of elements the user wants to make alterations to. If left
|
Value
The R6 grob matrix object class with its aesthetic / structure properties altered.
Examples
df = data.frame(var1 = c(5, 14, 6, 10), var2 = c(3, 30, 17, 7))
df %>%
grob_matrix() %>%
add_aesthetic(aesthetic = 'text_color', group = 'cells', value = 'red') %>%
alter_at(
.f = ~ 'blue',
abs(var2 - var1) > 1
) %>%
view_grob()
test_function = function(x) ifelse(x > 15, 2, 1)
df %>%
grob_matrix() %>%
alter_at(
.f = ~ test_function(.),
aesthetic = 'font_face',
group = 'cells'
) %>%
view_grob()
df %>%
grob_matrix() %>%
add_structure("column_widths_p", 1) %>%
alter_at(
.f = ~ 2,
columns = 1
) %>%
view_grob()