friedman.test(y, groups, blocks)
There must be exactly one element of y corresponding to each combination of the levels of groups and blocks.
The returned p.value should be interpreted carefully. It is only a large-sample approximation whose validity increases with the number of blocks.
Under the null hypothesis, the Friedman statistic has an asymptotic chi-square distribution with k - 1 degrees of freedom.
Lehmann, E. L. (1975). Nonparametrics: Statistical Methods Based on Ranks. Oakland, Calif.: Holden-Day.
treatments # a category object [1] 1 1 1 1 2 2 2 2 3 3 3 3 attr(, "levels"): [1] "Trt 1" "Trt 2" "Trt 3" people # a category object [1] 1 2 3 4 1 2 3 4 1 2 3 4 attr(, "levels"): [1] "Subject 1" "Subject 2" "Subject 3" "Subject 4" y # response [1] 0.73 0.76 0.46 0.85 0.48 0.78 0.87 0.22 0.51 0.03 0.39 0.44 friedman.test(y, treatments, people) # now suppose the data is in the form of a matrix. # generate 'y' and the category objects: y2 <- as.vector(tab.data) bl <- factor(as.vector(row(tab.data))) # if blocks are rows gr <- factor(as.vector(col(tab.data))) # if groups are columns friedman.test(y2, gr, bl) # same answer as above