Last chance! 50% off unlimited learning
Sale ends in
kruskal.test(x, ...)## S3 method for class 'default':
kruskal.test(x, g, \dots)
## S3 method for class 'formula':
kruskal.test(formula, data, subset, na.action, \dots)
x
. Ignored with a warning if
x
is a list.response ~ group
where
response
gives the data values and group
a vector or
factor of the corresponding groups.model.frame
) containing the variables in the
formula formula
. By default the variables are taken from
environment(formula)
.NA
s. Defaults to
getOption("na.action")
."htest"
containing the following components:"Kruskal-Wallis rank sum test"
.kruskal.test
performs a Kruskal-Wallis rank sum test of the
null that the location parameters of the distribution of x
are the same in each group (sample). The alternative is that they
differ in at least one. If x
is a list, its elements are taken as the samples to be
compared, and hence have to be numeric data vectors. In this case,
g
is ignored, and one can simply use kruskal.test(x)
to perform the test. If the samples are not yet contained in a
list, use kruskal.test(list(x, ...))
.
Otherwise, x
must be a numeric data vector, and g
must
be a vector or factor object of the same length as x
giving
the group for the corresponding elements of x
.
wilcox.test
) as the special
case for two samples;
lm
together with anova
for performing
one-way location analysis under normality assumptions; with Student's
t test (t.test
) as the special case for two samples. wilcox_test
in package
## Hollander & Wolfe (1973), 116.
## Mucociliary efficiency from the rate of removal of dust in normal
## subjects, subjects with obstructive airway disease, and subjects
## with asbestosis.
x <- c(2.9, 3.0, 2.5, 2.6, 3.2) # normal subjects
y <- c(3.8, 2.7, 4.0, 2.4) # with obstructive airway disease
z <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosis
kruskal.test(list(x, y, z))
## Equivalently,
x <- c(x, y, z)
g <- factor(rep(1:3, c(5, 4, 5)),
labels = c("Normal subjects",
"Subjects with obstructive airway disease",
"Subjects with asbestosis"))
kruskal.test(x, g)
## Formula interface.
require(graphics)
boxplot(Ozone ~ Month, data = airquality)
kruskal.test(Ozone ~ Month, data = airquality)
Run the code above in your browser using DataLab