[R] Using perm.t.test() upon Matrix/Dataframe columns parted by factor instead of t.test()

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Fri Jul 29 15:11:07 CEST 2011


Just a hunch I can't test from my phone, but in your final lapply you are passing a function of x that has no x in it, so I wouldn't be surprised if R was unhappy about that. 

Change the latter M's to x and see if that helps. 

Cheers 

Michael Weylandt 

On Jul 29, 2011, at 6:30 AM, Gunnar Oehmichen <oehm8895 at uni-landau.de> wrote:

> Hello dear subscribed Users,
> 
> this is my first post, so please forgive me for any inconveniences.
> 
> The following problem: I have a dataframe containing a factor column.
> For each column i would like to compare means as parted by the factor. Using the normal t.test function I have already achieved my goal. But i think, that for my original data, a permutational t.test would be better suited. Herein lies the problem. Whereas i can specify the factor as group parting in the formular expression I am not able to do this with perm.t.test() from deducer. Have fun with this trivial undergraduate problem.
> 
> Code:
> 
> c(rep("A", 5), rep("B", 5))->Faktor
> 
> matrix(rnorm(100, mean=20, sd=4), nrow=10, ncol=10)->M
> 
> colnames(M) <- c("species1","species2", "species3","species4","species5","species6","species7","species8","species9", "species10")
> 
> ###Conventional T-Test to test for differences of each species per factor
> 
> lapply(
>  M, function(x)
>  t.test(x~ Faktor)
>  )
> 
> ###Trying it for perm.t.test without the helpful formular expression. Does not work
> 
> lapply(
>  M, function(x)
>  perm.t.test(subset(M, Faktor=="A"),
>              subset(M, Faktor=="B"))
>  )
> 
> Thank you very much for your help,
> 
> Gunnar
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list