From ripley at stats.ox.ac.uk  Fri Oct 28 19:22:35 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 28 Oct 2005 18:22:35 +0100 (BST)
Subject: [Rd] Error in ?strsplit
In-Reply-To: <1130518957.4557.17.camel@localhost.localdomain>
References: <1130518957.4557.17.camel@localhost.localdomain>
Message-ID: <Pine.LNX.4.61.0510281819340.25410@gannet.stats>

Thanks, easy to correct.  We will explicitly say that a factor 'x' is 
erroneous.

On Fri, 28 Oct 2005, Marc Schwartz (via MN) wrote:

> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Error in ?strsplit
Prof Brian Ripley