Index: src/library/stats/R/kruskal.test.R =================================================================== --- src/library/stats/R/kruskal.test.R (revision 74631) +++ src/library/stats/R/kruskal.test.R (working copy) @@ -46,7 +46,10 @@ x <- x[OK] g <- g[OK] if (!all(is.finite(g))) - stop("all group levels must be finite") + if (is.character(g)) + stop("all group levels must be finite; convert group to a factor") + else + stop("all group levels must be finite") g <- factor(g) k <- nlevels(g) if (k < 2L) Index: src/library/stats/man/kruskal.test.Rd =================================================================== --- src/library/stats/man/kruskal.test.Rd (revision 74631) +++ src/library/stats/man/kruskal.test.Rd (working copy) @@ -22,11 +22,12 @@ \item{x}{a numeric vector of data values, or a list of numeric data vectors. Non-numeric elements of a list will be coerced, with a warning.} - \item{g}{a vector or factor object giving the group for the + \item{g}{a numeric vector or factor object giving the group for the corresponding elements of \code{x}. Ignored with a warning if \code{x} is a list.} \item{formula}{a formula of the form \code{response ~ group} where - \code{response} gives the data values and \code{group} a vector or + \code{response} gives the data values and \code{group} + a numeric vector or factor of the corresponding groups.} \item{data}{an optional matrix or data frame (or similar: see \code{\link{model.frame}}) containing the variables in the @@ -52,7 +53,8 @@ list, use \code{kruskal.test(list(x, ...))}. Otherwise, \code{x} must be a numeric data vector, and \code{g} must - be a vector or factor object of the same length as \code{x} giving + be a numeric vector or factor object of the same length as \code{x} + giving the group for the corresponding elements of \code{x}. } \value{