Re: [R] indicating significant differences in boxplots
Hi, I'd like to follow up an older discussion on adding significance stars to boxplots. ( http://r.789695.n4.nabble.com/indicating-significant-differences-in-boxplots-td862335.html ) As suggested by Jim Lemon, there is following solution for a single boxplot: boxplot(count ~ spray, data = InsectSprays, col = lightgray) #and we'll assume that the second and third boxplots require a star: par(xpd=TRUE) yrange-par(usr)[3:4] ypos-yrange[2]+diff(yrange)/40 segments(2,ypos,3,ypos) text(2.5,ypos+diff(yrange)/40,*,cex=2) par(xpd=FALSE) But what if one wants to plot two boxplots (e.g. with each only two groups which are significantly different) and add such stars to each of the boxplots. I usually use par(mfrow(1,2)) to plot all boxplots in a row. How can I also add segments and stars on top of each plot? /johannes [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] indicating significant differences in boxplots
On 10/29/2013 01:51 AM, Johannes Radinger wrote: Hi, I'd like to follow up an older discussion on adding significance stars to boxplots. ( http://r.789695.n4.nabble.com/indicating-significant-differences-in-boxplots-td862335.html ) As suggested by Jim Lemon, there is following solution for a single boxplot: boxplot(count ~ spray, data = InsectSprays, col = lightgray) #and we'll assume that the second and third boxplots require a star: par(xpd=TRUE) yrange-par(usr)[3:4] ypos-yrange[2]+diff(yrange)/40 segments(2,ypos,3,ypos) text(2.5,ypos+diff(yrange)/40,*,cex=2) par(xpd=FALSE) But what if one wants to plot two boxplots (e.g. with each only two groups which are significantly different) and add such stars to each of the boxplots. I usually use par(mfrow(1,2)) to plot all boxplots in a row. How can I also add segments and stars on top of each plot? Hi johannes, The general strategy above can be applied. Fortunately, boxplots are centered on successive integers (i.e. 1,2,...) by default. The calculations for ypos yield 1/40th of the vertical span of the plot above the top of the plot. Just add the segments and stars after each plot, as each boxplot advances to the next frame in your plot matrix. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] indicating significant differences in boxplots
Hi all! Writing a paper using a lot of boxplots I was asked to mark the significant differences between plotted groups using stars on top. These stars are found freqeuntly in medical papers and printed above boxplots when there is a significant difference (usually using a bar to indicate which groups are meant if there are more then two in a plot). I was able to calculate whatever test, check the significance and depending on it to put a star (written with text-function) between two groups in a boxplot. But I was not able to make the text between two groups apear above the actual plotting region nor to draw a simple line, indicating which plots are meant. Also this solution seems to more of a hack then actual programming. Is there a better way to solve this issue? Any ideas where to look? I hope I haven been clear and thank you for your effort, S. Merz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] indicating significant differences in boxplots
On Mon, 2008-07-07 at 11:19 +0200, Sebastian Merz wrote: Hi all! Writing a paper using a lot of boxplots I was asked to mark the significant differences between plotted groups using stars on top. These stars are found freqeuntly in medical papers and printed above boxplots when there is a significant difference (usually using a bar to indicate which groups are meant if there are more then two in a plot). I was able to calculate whatever test, check the significance and depending on it to put a star (written with text-function) between two groups in a boxplot. But I was not able to make the text between two groups apear above the actual plotting region nor to draw a simple line, indicating which plots are meant. Also this solution seems to more of a hack then actual programming. Is there a better way to solve this issue? Any ideas where to look? Hi Sebastian, If I understand you correctly, try this boxplot example: boxplot(count ~ spray, data = InsectSprays, col = lightgray) and we'll assume that the second and third boxplots require a star: par(xpd=TRUE) yrange-par(usr)[3:4] ypos-yrange[2]+diff(yrange)/40 segments(2,ypos,3,ypos) text(2.5,ypos+diff(yrange)/40,*,cex=2) par(xpd=FALSE) With a bit more effort, you could set up tests of differences, collect the significant ones and automatically call a function like the above that would stick stars above the significantly different groups. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] indicating significant differences in boxplots
HI Sebasian, I don't think I have ever seen this type of presentation. Could you provide a reference to a journal article that uses this? It might make it easier to visualize exactly what you want. --- On Mon, 7/7/08, Sebastian Merz [EMAIL PROTECTED] wrote: From: Sebastian Merz [EMAIL PROTECTED] Subject: [R] indicating significant differences in boxplots To: r-help@r-project.org Received: Monday, July 7, 2008, 5:19 AM Hi all! Writing a paper using a lot of boxplots I was asked to mark the significant differences between plotted groups using stars on top. These stars are found freqeuntly in medical papers and printed above boxplots when there is a significant difference (usually using a bar to indicate which groups are meant if there are more then two in a plot). I was able to calculate whatever test, check the significance and depending on it to put a star (written with text-function) between two groups in a boxplot. But I was not able to make the text between two groups apear above the actual plotting region nor to draw a simple line, indicating which plots are meant. Also this solution seems to more of a hack then actual programming. Is there a better way to solve this issue? Any ideas where to look? I hope I haven been clear and thank you for your effort, S. Merz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.