使用 twiddle 生成图(内联匿名函数)

Generating plots by using twiddle (inline anonymous functions)

我正在尝试编写一个管道,根据 attrition 数据为每个部门创建年龄直方图。我想使用 内联匿名函数 通过 twiddle 使用 map().

我尝试了以下方法,但仍然不知道如何从中生成直方图。

attrition %>%
  nest(data = Department) %>%
  mutate(gg = map(data, ~ .x + theme(text = element_text(color = 'blue')))) %>%
  pull(gg)

mtcars为例:

library(tidyverse)

mtcars %>%
  nest(data = -cyl)  %>%
  mutate(gg = map(data, ~ ggplot(.x) + aes(mpg) + geom_histogram())) %>%
  pull(gg)

这会给你地块列表。