Bug 16719 - kruskal.test documentation for formula
Summary: kruskal.test documentation for formula
Alias: None
Product: R
Classification: Unclassified
Component: Documentation (show other bugs)
Version: R 3.2.3
Hardware: Other Other
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2016-02-18 22:50 UTC by k_bugzilla
Modified: 2016-02-18 22:50 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description k_bugzilla 2016-02-18 22:50:29 UTC
R version 3.2.3

from ?kruskal.test:
a formula of the form response ~ group where response gives the data values and group a vector or factor of the corresponding groups."

mtcars$type <- rep(letters[1:2], c(16, 16))
is.vector(mtcars$type) ## TRUE

kruskal.test(mpg ~ type, mtcars)
## Error in kruskal.test.default(c(21, 21, 22.8, 21.4, 18.7, 18.1, 14.3,  : 
##   all group levels must be finite

mtcars$type <- rep(1:2, c(16, 16))
kruskal.test(mpg ~ type, mtcars) # works

mtcars$type <- factor(mtcars$type)
kruskal.test(mpg ~ type, mtcars) # works

Maybe instead of 'vector' it should read 'numeric'? Or should kruskal.test also work with 'character' for grouping?