Skip to content
Prev 207903 / 398502 Next

using functions with multiple arguments in the "apply" family

chipmaney wrote:
Your example data makes little sense; you have precisely the
same data for both sites and you have only two sites (why do
kruskal.test on two sites?). Finally, you need to decide what
your response variable is: 'Score' or 'Indicator_Rating'.

So here's some made-up data and the use of by() to apply
the test to each site:

dat <- data.frame(y = rnorm(60), yr=gl(4,5,60), st=gl(3,20))
with(dat, by(dat, st, function(x) kruskal.test(y~yr, data=x)))

See the last example in ?by.

  -Peter Ehlers