r - using fun.y in ggplot -
i absolute beginner. so, apologize asking basic question. trying plot minimum value in dataset. looked @ following page (changing y scale when using fun.y ggplot) , didn't find solution.
here's first code: works well. plotsa red dot @ mean.
ggplot(mpg, aes(trans, cty)) + geom_point() + stat_summary(geom = "point", fun.y = "mean", colour = "red", size = 4)
this 1 doesn't work. can please me?
ggplot(mpg, aes(trans, cty)) + geom_point() + stat_summary(geom = "point", fun.ymin = min, colour = "red", size = 50)
i not sure what's going on.
in stat_summary
, plot depends on geom
choose. seem want plot points, chose geom = 'point'
. point has single y value, fun.y
used summary.
there other arguments, fun.ymin
, fun.ymax
. isn't super clear in documentation, needed if using geoms take additional aesthetics. example, geom = 'pointrange'
plots point , vertical bar ymin
, ymax
:
ggplot(mpg, aes(trans, cty)) + geom_point() + stat_summary(geom = 'pointrange', fun.ymin = min, fun.ymax = max, fun.y = mean, colour = "red", size = 1)
in case, ggplot
coded in adaptable way can pass name of function character string, fun.ymin = 'min'
, or can pass function directly, fun.ymin = min
.
Comments
Post a Comment