# ANOVA testing by group
data %>%
group_by(your_group) %>%
do(tidy(aov(y ~ factor(x), data = .))) %>%
select(your_group, p.value)
# CHISQUARE testing by group
data %>%
group_by(your_group) %>%
summarise(pvalue = chisq.test(x, y)$p.value) %>%
mutate(pvalue = ifelse(pvalue > 0.001, sprintf("%.3f", pvalue), ">.001"))
# TRENDS testing for repeated measures
library(lmer)
library(lmerTest)
mod1 <- lmer(y ~ group*time + (1|group_id), data = your_data, REML = FALSE)
# note that time here is categorical.
# for continuous time, please do not use this model
# note that group and group_id are not the same
# group_id is the repeated measure id
# group_ids will be a subset of the 2 or more groups
anova(mod1)
# output should say:
# "Analysis of Variance Table of type III w/ Satterthwaite..."
# extract p-value from interaction term