【发布时间】:2020-12-04 11:55:07
【问题描述】:
我正在尝试编写一个创建条形图的函数,但我无法获得正确的 fill 美学。
- 如果我使用
fill = !!x会导致Quosures can only be unquoted within a quasiquotation context. - 和
fill = x导致Aesthetics must be either length 1 or the same as the data (4): fill
我的代码:
genBar <- function(data, x, y) {
x <- enquo(x)
y <- enquo(y)
plot <- ggplot(data) +
geom_bar(aes(!!x, !!y),
stat = 'identity',
fill = <help>)
return(plot)
}
【问题讨论】: