adjusting the number of significant values using stat_summary

5 views
Skip to first unread message

Jeremy Ng

unread,
May 15, 2013, 8:59:01 PM5/15/13
to ggp...@googlegroups.com, Jeremy Ng
Hi guys,

I want to adjust the number of significant values that is shown in my mean labels, but this mean is computed from a data-frame (fun.data). 

This is how my code looks like:

scoresforplotting <- cbind(intensityValues,groupings)

averagesforplotting <- function(x){
  return(c(y=mean(x), label=mean(x)))
  }

ggplot(scoresforplotting, aes(groupings, intensityValues))+geom_boxplot()+stat_summary(fun.data=averagesforplotting,geom="text")

The aes argument in ggplot nicely handles the grouping. However the stat_summary part is what I am stuck at. The function averagesforplotting would help me to compute the group means, but however the means have too many significant figures. Can someone provide some lead as to how I can go about with reducing the number of significant figures that is shown on the labels? 

Thanks!
Jeremy
Reply all
Reply to author
Forward
0 new messages