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

See Also:


Attachments

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:
"formula
a formula of the form response ~ group where response gives the data values and group a vector or factor of the corresponding groups."

data(mtcars)
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?