From mschwartz at mn.rr.com  Fri Oct 28 19:02:37 2005
From: mschwartz at mn.rr.com (Marc Schwartz (via MN))
Date: Fri, 28 Oct 2005 12:02:37 -0500
Subject: [Rd] Error in ?strsplit
Message-ID: <1130518957.4557.17.camel@localhost.localdomain>

Hi all,

Came across an error in ?strsplit in the details section:

Details:

     Arguments 'x' and 'split' will be coerced to character, so you
     will see uses with 'split = NULL' to mean 'split = character(0)',
     including in the examples below.


I caught myself trying to use strsplit() on a factor and the coercion on
'x' is not done.


According to the ONEWS file, the coercion on 'x' was removed in 1.8.0:

   o	strsplit(x, *) now preserves names() but won't work for
	non-character `x' anymore {formerly used as.character(x),
	destroying names(x)}.


The function prototype is:

> strsplit
function (x, split, extended = TRUE, fixed = FALSE, perl = FALSE)
.Internal(strsplit(x, as.character(split), as.logical(extended),
    as.logical(fixed), as.logical(perl)))
<environment: namespace:base>


So 'split' is coerced, but not 'x'.


This is on:

Version 2.2.0 Patched (2005-10-27 r36070)


A proposed patch is:


--- strsplit.Rd 2005-10-06 07:50:36.000000000 -0500
+++ strsplit.rev.Rd     2005-10-28 11:51:08.000000000 -0500
@@ -37,7 +37,7 @@
   contains the vector of splits of \code{x[i]}.
 }
 \details{
-  Arguments \code{x} and \code{split} will be coerced to character, so
+  Argument \code{split} will be coerced to character, so
   you will see uses with \code{split = NULL} to mean
   \code{split = character(0)}, including in the examples below.



HTH,

Marc Schwartz



[Rd] Error in ?strsplit
Marc Schwartz (via MN