Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomatic grouping of treatments in graph by significant differences in r
    text
    copied!<p>In my work I often have to make different treatment comparisons using Anova and Tukey tests to determine which of multiple treatments in one factor experiments are statistically distinct from one another. </p> <p>The code I have attached yields two separate <a href="http://imgur.com/a/fkalq" rel="nofollow">figures</a>: one with treatment distribution of values (example graph1) and another with the Tukey test results showing which pair of treatments are significantly different from one another (example graph2). </p> <p>What I have done in the past is to look at the Tukey results and manually edit the first graph with letters indicating groups of statistically equivalent groups (example graph3). I have been looking at different r libraries for ways to automatically produce something similar to graph 3 that summarizes such groupings but have not yet found a way. Does anyone have any suggestions?</p> <p>PS- I am sorry if the graph routine below is a little cumbersome, but it is essentially a fragment of a much more comprehensive set of functions that I have developed to test data distribution, conditionally apply relevant tests and produce output tables and figures. </p> <p>The code I have written to make the first two graphs is below. t?usp=sharing</p> <pre><code>Group=c("G1","G1","G1","G1","G2","G2","G2","G2","G3","G3","G3","G3") Vals=c(runif(4),runif(4)+0.5,runif(4)+0.1) data=data.frame(Group) data=cbind(data, Vals) anova_results=aov(Vals~Group,data=data) anova_results2=anova(anova_results)[1, ] anova_significance=anova_results2[1,"Pr(&gt;F)"] significant=anova_significance[1]&lt;=0.05 if (significant==1) { Tukey_results=TukeyHSD(anova_results,"Group") Tukey_results=Tukey_results$Group } plot(data$Group, data$Vals) if (significant==1) { plot(TukeyHSD(anova_results,"Group"), las=1) } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload