[R] Get output values in a table

Phil Spector spector at stat.berkeley.edu
Tue May 25 22:40:16 CEST 2010


Iurie -
    The help file for both functions has a "Values" section
that describes in detail exactly what the function returns.
In both cases, you'll see there is a component named
"statistic", which is what you want.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu



On Tue, 25 May 2010, Iurie Malai wrote:

> Hi,
>
> I use two similar scripts to put p-values of shapiro.test and, respectively,
> of wilcox.test in a table:
>
> a)
> d <- data.frame(dataset$GroupFactor, dataset[2:11])
> # p-values for the shapiro test (by levels of GroupFactor)
> with(d, aggregate(d[,-1], list(d[,1]), FUN = function(x)
> shapiro.test(x)$p.value))
>
> b)
> d <- data.frame(dataset$GroupFactor, dataset[2:11])
> with(d, aggregate(d[,-1], list(d[,1]), FUN = function(x)
> wilcox.test(x)$p.value))
>
> How to replace the p-values with values of "W" (for Shapiro-Wilk test and,
> respectively, for Wilcoxon-Mann-Whitney U test)?
>
> Example of output:
> ---------------------------
>> with(d, aggregate(d[,-1], list(d[,1]), FUN = function(x)
> shapiro.test(x)$p.value))
>  Group.1            1          2        3           4            5
> 6         7         8      IA        IV
> 1   town 0.0030465882 0.002068448 0.01129771 7.606061e-06 1.189380e-03
> 0.001396341 0.009097276 6.824918e-05 0.4877525 0.08005584
> 2   country 0.0002436141 0.005135004 0.01540923 2.469611e-06 1.372854e-05
> 0.001517259 0.052174738 1.057227e-06 0.3172002 0.15745973
>
>
> Regards,
> Iurie Malai
> Department of Psychology
> Ion Creanga Moldova Pedagogical State University - www.upsm.md
> http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_University
>



More information about the R-help mailing list