Error in layer - "unused argument (fun.data = median_hilow)"

#Hello, I am trying to run a graph command from tidyverse, ggplot(). I intend to
#summarize the y values for each unique x value. For that I have used commands
#from <http://rstudio-pubs-static.s3.amazonaws.com/3358_2def158be48047a6944bfcc60ea08f1b.html>
#It keeps running on error!
library(tidyverse)
ggplot(data = diamonds, mapping = aes(x = cut, y = depth))+
layer(geom = "pointrange", stat="summary", fun.data = median_hilow)
#"Error in layer(geom = "pointrange", stat = "summary", fun.data = median_hilow) :
#unused argument (fun.data = median_hilow)"
#Can anyone help me please?

Are you looking for something like this? The Hmisc package must be installed for this to work. The default geom for stat_summary is pointrange.

library(ggplot2)
DF <- data.frame(Grp <- rep(LETTERS[1:4], each = 20), Value = rnorm(80))
ggplot(DF, aes(x = Grp, y = Value)) + stat_summary(fun.data = median_hilow)

Created on 2020-06-04 by the reprex package (v0.3.0)

#Yes, it does pretty much what I have been looking for! Thank you. I also generated the
#same graph using geom_pointrange():
library(tidyverse)
ggplot(data=diamonds, mapping = aes(x=cut, y=depth))+
geom_pointrange(stat="summary", fun.data=median_hilow)
#Although library(Hmisc) is not necessary in this case, I don't know if having installed
#the package as you suggested (and I did) played any role in the command above!

#Thank you again,

#[n]

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.