[R] Friedman test

Agustin Lobo aloboaleu at gmail.com
Thu Sep 24 15:07:36 CEST 2015

I would like to make sure that I'm using friedman.test() correctly,
because I have to reformat my data set to fulfil the requirement
"exactly one observation in y for each combination of levels of groups
and blocks" mentioned
in the help page of function friedman.test().

Assuming data from

treatments <- factor(rep(c("Trt1", "Trt2", "Trt3"), each=4))
people <- factor(rep(c("Subj1", "Subj2", "Subj3", "Subj4"), 3))
y <- c(0.73,0.76,0.46,0.85,0.48,0.78,0.87,0.22,0.51,0.03,0.39,0.44)
midata <- data.frame(treatments,people,y)

I would do as follows:

Test among treatments
friedman.test(y ~ treatments|people,data=midata)
Test among subjects
friedman.test(y ~ people|treatments,data=midata)

Is this correct?


Agustin Lobo
aloboaleu at gmail.com

More information about the R-help mailing list