【发布时间】:2021-08-20 13:11:59
【问题描述】:
我在 ggplot 的实验室中使用 curly curly,它似乎不起作用,如何在尝试 #2 中的 ggplot 实验室中使用标签。对于 Try#3,我想通过函数中的 purr 传递所有数值变量。
尝试 #1 - 这行得通
library(tidyverse)
myplot <- function(df,col) {
df %>%
ggplot(aes(x={{col}}))+
geom_histogram()+
# labs(title=paste0("Histogram for ",{{col}}))+
theme_classic()
}
myplot(iris,Sepal.Length)
尝试 #2 - 这不起作用
myplot <- function(df,col) {
df %>%
ggplot(aes(x={{col}}))+
geom_histogram()+
labs(title=paste0("Histogram for ",{{col}}))+
theme_classic()
}
myplot(iris,Sepal.Length)
尝试 #3 - 这也不起作用
myplot <- function(df,col) {
df %>%
ggplot(aes(x={{col}}))+
geom_histogram()+
theme_classic()
}
iris[,-5] %>%
map(myplot)
【问题讨论】: