ggplot stat_summary未使用的参数(df $ y)

时间:2019-02-11 17:39:45

标签: r ggplot2 boxplot

我正在尝试使用真正的“ min”和“ max”晶须(仅一个变量)使boxplot graph函数起作用。自变量“ y”为data_frame$variable_name

function(y) {
  i <- function() {
    r <- quantile(na.omit(y), probs = c(0.00, 0.25, 0.5, 0.75, 1))
    names(r) <- c("ymin", "lower", "middle", "upper", "ymax")
  }
  ggplot(NULL, aes(x = 1, y = na.omit(y)))+
    stat_summary(fun.data = i, geom = "boxplot")
}

发生下一个错误

Warning message:
Computation failed in `stat_summary()`:
unused argument (df$y) 

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

要标记:

谢谢,它可以使用。

function (y) {
ggplot()+
geom_boxplot(
aes(x = NA, ymin = min(y), lower = quantile(y,0.25), middle = median(y),
upper = quantile(y,0.75),ymax = max(y)),
stat="identity")+
geom_errorbar(aes(x = NA,ymin = min(y), ymax = max(y)), width= 0.5)+
geom_jitter(aes(x = NA,y = y))
}