r - 使用 twiddle 生成绘图(内联匿名函数)
问题描述
我正在尝试编写一个管道来根据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)
这将为您提供地块列表。
推荐阅读
- php - 如何在准备好的语句中绑定“DEFAULT”和“NULL”?
- node.js - 如何测试已触发的事件及其值?
- firebase - firebase 功能无法部署
- javascript - ReferenceError Html 和 JavaScript
- css - 为什么 svg 在重新加载时会显示调整大小(以一种不受欢迎的方式),但在强制重新加载时会正确呈现?
- php - 从 FTP 下载文件,同时保留原始的“最后更改”日期
- javascript - 钩画布的 toDataURL
- java - Java - 将泛型类型映射到所述类型的使用者
- r - 提取单元格组合而不重复索引
- frama-c - Frama-C EVA插件中“后”栏的含义和目的是什么