[R] Using perm.t.test() upon Matrix/Dataframe columns parted by factor instead of t.test()
Gunnar Oehmichen
oehm8895 at uni-landau.de
Fri Jul 29 12:30:57 CEST 2011
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
More information about the R-help
mailing list