0

I'm trying to use the boxplot() function in R to show the 10th and 95th percentiles, rather than the 1.5*IQR by default. People have provided solutions on this forum but none of them seem to work for me.

For all my initial few box plots I used ggplot2 which worked great. However, recently I discovered that stat_summary plotted the mean in the wrong place for one of the sites I'm studying during summer.Image generated by ggplot2 I could only resolve this using Boxplot() using the following;

 boxplot(mydata$tgm~interaction(mydata$site, mydata$season), 
         las = 1,
         names = c("BFa", "MBa", "STa", "BFsp", "MBsp", "STsp", "BFsu", "MBsu", "STsu", "BFw", "MBw", "STw"), 
         col = c("royalblue", "red", "green", "royalblue", "red", "green", "royalblue", "red", "green", "royalblue", "red", "green"), 
         outline = FALSE, 
         xlab = "Site per season", 
         ylab = "TGM concentration (ng/m3)")

And then:

means <- aggregate(mydata$tgm~interaction(mydata$site, mydata$season), data = mydata, mean)

points(means, col = "black", pch = 16)

Is there anyway for me to alter my argument so that the 10th and 90th percentiles are displayed?

  • `stat_summary` plotted mean in the wrong place? what do you mean? show us some data. Please read [How to make a great reproducible example in R?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – M-- Jul 19 '17 at 15:52
  • I've attached a link to the image generated by ggplot 2. The mean is plotted below the median, but according to the statistical summary generated by R (mean = 2.385, and median = 2.383). – Monray Dean Belelie Jul 20 '17 at 09:07
  • Have you read the link that I provided. Without providing a reproducible example it is unlikely that you'd get help. – M-- Jul 20 '17 at 13:16

0 Answers0