Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9296541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:51:12+00:00 2026-06-18T21:51:12+00:00

In my work I often have to make different treatment comparisons using Anova and

  • 0

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.

The code I have attached yields two separate figures: 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).

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?

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.

The code I have written to make the first two graphs is below. t?usp=sharing

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(>F)"]
significant=anova_significance[1]<=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)   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:51:13+00:00Added an answer on June 18, 2026 at 9:51 pm

    Roman Lustrik’s suggestions on the comments above were spot on. I ended up finding two alternative ways to do it based on two related libraries. After running the code posted in the question, to create the grouped treatment plots run:

    #simple looking solution
    library(multcomp)
    tuk <- glht(anova_results, linfct = mcp(Group = "Tukey"))
    summary(tuk)          # standard display
    tuk.cld <- cld(tuk)   # letter-based display
    opar <- par(mai=c(1,1,1.5,1))
    plot(tuk.cld)
    par(opar)
    
    #more fancy looking solution using the multcompView library with a lot of ways to 
    #alter the plot appearance as necessary
    library(multcompView)
    multcompBoxplot(Vals~Group,data=data)
    
    # Now, the solution below is my favorite solution as the text direction of the groups 
    #work very well if you have many treatments that you are comparing
    opar <- par()  
    par(oma = c(6, 0, 0, 0)) #extra space for extra large treatment names
    xzx <-multcompBoxplot(Vals~Group,data=data,sortFn=median,  decreasing=FALSE,    
                          horizontal=FALSE,
                          plotList=list(
                            boxplot=list(fig=c(0,  1,  0,  1),  las=3,
                                         cex.axis=1.5),                      
                            multcompLetters=list(
                              fig=c(0.87,  0.97,  0.115,  0.923), #0.1108, 0.9432 Top of     
    #page 18 manual for very convoluted explanation (c(y bottom, y top,x L, x R))
                              type='Letters') ) )
    par(opar)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the company that I work with, we often have to integrate with client’s
Is there any way to do it? I often have issues that work locally
I often work in Eclipse, but recently switched to TextMate, which is, in my
For my work I have to set up a project in Matlab, which is
I have multiple <div> tag with same width but different height in a container.
I often work with multidimensional arrays whose array indices are generated from a complicated
As a freelancer, I often work at companies who use Subversion repositories. It’d be
At my company, we develop our ASP.NET applications as websites and often just work
I often like to create backups when testing the software I work on, and
I often want to send sample apps to friends & colleages that work with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.