I need to perform multiple pairwise ANOVA's in R, and correct the p-values using bonferroni. However I don't need to compare every CLASS to each other. Below is my data format and selcontrasts
: the pairs of which I need to contrast the log10relquant. Does any of you know how I could execute this? I use the dplyr
, lsmeans
and broom
packages.
SEX EXPERIENCED AGE CLASS compound relquant log10relquant
1 FEMALE NO 1D 1F C14 0.004012910 -2.396541
2 FEMALE NO 1D 1F C14 0.003759812 -2.424834
3 FEMALE NO 1D 1F C14 0.003838553 -2.415832
4 FEMALE NO 1D 1F C14 0.003582754 -2.445783
5 MALE NO 1D 1M C14 0.005099237 -2.292495
6 MALE NO 1D 1M C14 0.005379093 -2.269291
selcontrasts <- c("1F - 1M", "4F - 4M", "4EF - 4EM",
"7F - 7M", "7EF - 7EM", # sex differences
"1M - 4M", "4M - 7M", "1M - 7M", "1F - 4F",
"4F - 7F", "1F - 7F", # age differences
"4M - 4EM", "7M - 7EM", "4F - 4EF",
"7F - 7EF" # social experience)
x=list(selcontrasts)
Currently I'm using this to pair the whole dataset (so to compair every class) instead of the selected contrasts:
pvalsage=data.frame(datagr %>%
do( data.frame(summary(contrast(lsmeans(
aov(log10relquant ~ CLASS, data = .), ~ CLASS ),
method="pairwise",adjust="none"))) ))
To only do the selected contrasts in list x, I tried:
pvalsage=data.frame(datagr %>%
do(data.frame(summary(contrast(lsmeans(
aov(log10relquant ~ CLASS, data = .),~ CLASS),
method = x, adjust="none"))) ))
But I get the error:
error in contrast.ref.grid(lsmeans(aov(log10relquant ~ CLASS, data = .), :
Nonconforming number of contrast coefficients