[R] extracting results from wilcox_test (package::coin)

chipmaney chipmaney at hotmail.com
Wed Feb 24 20:56:49 CET 2010


Recently, I ran a series of Kruskal-Wallace tests [kruskal.test()] using by()
to group by site  Output is a list:

>Herb.KW
Herb.df$ID: 10-1

        Kruskal-Wallis rank sum test

data:  Indicator_Rating by Year 
Kruskal-Wallis chi-squared = 15.24, df = 7, p-value = 0.03302

-----------------------------------------------------------------------------------------------------
Herb.df$ID: 18-1

        Kruskal-Wallis rank sum test

data:  Indicator_Rating by Year 
Kruskal-Wallis chi-squared = 13.56, df = 7, p-value = 0.05963

-----------------------------------------------------------------------------------------------------
Herb.df$ID: 18-10

        Kruskal-Wallis rank sum test

data:  Indicator_Rating by Year 
Kruskal-Wallis chi-squared = 16.65, df = 5, p-value = 0.005213

------------------------------------------------------------------------------------------------------

I used the following code to extract a vector of p.values for each list
element:

> sapply(Herb.KW, '[[', 'p.value')
     10-1      18-1     18-10     18-11     18-12     18-13      18-2     
18-3      18-4      18-5      18-6       
3.302e-02 5.963e-02 5.213e-03 1.321e-09 4.483e-04 2.823e-02 2.893e-03
2.535e-02 5.701e-03  
      3-1     37-15     37-16     37-17     37-20     37-21     37-23    
37-24     37-25     37-26      
3.552e-18 9.189e-01 4.051e-03 2.122e-09 1.325e-01 2.128e-03 4.543e-01
9.940e-02 1.748e-02  
      
I then used wilcoxon_test for post-hoc analysis, which also returns a LIST
with sites as elements.  However, when I try to extract a pvalue from the
list elements, I get the following message:

>sapply(Herb.Wilcox, '[[', 'p.value')

Error in FUN(X[[1L]], ...) : object of type 'S4' is not subsettable

First, how do I determine what the "values" (e.g., statistic, pvalue) of the
model output are, because the reference manual does not say (unlike for
kruskal.test)...is the value object named "p.value" or "pvalue" or
"p-value"??? Is the statistic named "statistic" or "Z.statistic" or
"U.statistic"????

Second, why isn't this object not subsettable even though class=list? how do
i get around this problem and extract the statistic and p-value for each
element in the list?


-- 
View this message in context: http://n4.nabble.com/extracting-results-from-wilcox-test-package-coin-tp1567956p1567956.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list