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 6738975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:25:57+00:00 2026-05-26T11:25:57+00:00

This is the normal output from the test: attach(airquality) pw <- pairwise.wilcox.test(Ozone, Month, p.adj

  • 0

This is the normal output from the test:

attach(airquality)
pw <- pairwise.wilcox.test(Ozone, Month, p.adj = "bonf")
pw

data:  Ozone and Month 

     May    Jun    Jul    Aug   
Jun 1.0000 -      -      -     
Jul 0.0003 0.1414 -      -     
Aug 0.0012 0.2591 1.0000 -     
Sep 1.0000 1.0000 0.0074 0.0325

I recently had to conduct a test with 10 levels of a factor. While the lower triangular format of the pairwise.wilcox.test is useful and concise, I thought it would be convenient to arrange it in a simlar way to the Tukey HSD output where each pairwise combination is listed along with it’s asociated p value. This was my attempt to do this:

pw.df <- as.data.frame(pw$p.value)
pw.diff <- vector("character")
pw.pval <- vector("numeric")
for (i in 1:ncol(pw.df) )
  for (j in i:length(pw.df) ) {
    pw.diff <- c(pw.diff,paste(colnames(pw.df[i]),"-",rownames(pw.df)[j]))
    pw.pval <- c(pw.pval,pw.df[j,i])
  }


# order them by ascending p value
v <- order(pw.pval,decreasing = F)
pw.df <- data.frame(pw.diff[v],pw.pval[v])


# display those that are significant at the 5% level
pw.df[pw.df$pw.pval<0.05,]

  pw.diff.v.  pw.pval.v.
1  May - Jul 0.000299639
2  May - Aug 0.001208078
3  Jul - Sep 0.007442604
4  Aug - Sep 0.032479550

If anyone has some tips/tricks/advice on how to make this easier and/or more elegant I would be grateful.

  • 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-05-26T11:25:58+00:00Added an answer on May 26, 2026 at 11:25 am

    I would use the reshape or reshape2 package for this task, specifically the melt() command. The object returned by pairwise.wilcox.test contains the data of interest in the third slot, so something like melt(pw[[3]]) should do the trick:

        X1  X2       value
    1  Jun May 1.000000000
    2  Jul May 0.000299639
    3  Aug May 0.001208078
    4  Sep May 1.000000000
    5  Jun Jun          NA
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from this (normal dataGrid) (source: narod.ru ) into this (horisontal data grid) How to
I keep getting this weird output from my code everytime I use the 'start
What's up with this, how do I capture the output from my Gambit-C program?
Yes i am having an normal output from the database of a message, with
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
I am wondering is this normal when you add this into your web.config <location
Resharper doesn't recognise Rowtests, is this normal? Is there anyway to fix it? (
I'm trying to figure out if this is normal. Because without errors, a connection
can I make my own headers in HTTP request ? e.g. This is normal
In Delphi, is normal do this: ob = TObject.create; try //code finally ob.free; end;

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.