我使用3个因子变量和一个百分比变量得到以下df:
df <- data.frame(
group = rep(c("Case", "Control"), each=16),
timing = rep(c("T0", "T1", "T2", "T3"), each=4, times=2),
food.type = rep (c("Very healthy", "Healthy", "Unhealthy", "Very bad"), times = 8),
intake.percentage = runif(32, min=1, max=25)
)
我如何进行测试(chi平方)以评估每种食物的组(病例;对照)之间每次(T0-T3)的统计学差异?
为方便起见,可以帮助您理解的情节:
ggplot(df, aes(x = timing,y = intake.percentage, group=group)) +
geom_line(aes(colour=group)) +
geom_point(aes(colour=group, shape=group), size=3) +
theme_light(16) +
facet_grid(facets = .~food.type, scales = 'free')