Thomas Levine writes:
> I have yet to find any example of my proposed changes causing a
> regression. I believe that the most reasonable thing that it might
> break is something that depends on either kruskal.test raising an
> error or that depends on the specific text in the error message.
>
> If the limited testing is a concern, I could find a way to install
> all of the packages and run all of their examples.

In case my April message is hard to find, I have attached the packages
redundantly to this email.
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{
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)
@@ -45,7 +45,7 @@
         OK <- complete.cases(x, g)
         x <- x[OK]
         g <- g[OK]
-        if (!all(is.finite(g)))
+        if (!is.character(g) & !all(is.finite(g)))
             stop("all group levels must be finite")
         g <- factor(g)
         k <- nlevels(g)
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,13 @@
   \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 character vector, numeric vector, or factor
+    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
+    character vector, 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 +54,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, character vector, or factor of the same length
+  as \code{x} giving
   the group for the corresponding elements of \code{x}.
 }
 \value{
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to