map_grob: Purrr style map across categories with grobs.

Description Usage Arguments Details Value Note

View source: R/map_grob.R

Description

A function similar to dplyr::group_map(), but returning a grob list (grid::gList()).

Usage

1
map_grob(.data, .f, by, values, ...)

Arguments

.data

A data frame to map. Must include columns referred to in by and values.

.f

A function to apply to groupings of .data (grouped by by).

by

The name of the grouping variable.

values

The name of the value variable to pass to f

...

Any additional parameters to pass to f.

Details

The map-style functions are great for applying a function across a series of data, particularly the dplyr::group_map().

This function wraps dplyr::group_map(), so that a grid::gList() is returned for use in grob-related functions. So the class of the list is set to gList, as is done in the grid::gList() function.

A mapped function is expected to take two fixed parameters, the grouped data frame and a tibble representing the group_by variable names. The function must also take a x parameter that specifies the x variable (assuming the y is the group_by variable).

Value

A grid::gList() of grid::grob() that result from calling f from X$values, grouped by X$by.

Note

The by must be a factor, since we extract the numeric value currently to use in the called function. The assumption would be that by will represent a coordinate within the grob (though it's not required to).


steveneschrich/densityplots documentation built on Dec. 23, 2021, 5:32 a.m.