From ripley at stats.ox.ac.uk  Wed May  9 07:41:23 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 9 May 2007 06:41:23 +0100 (BST)
Subject: [Rd] grep with fixed=TRUE and ignore.case=TRUE
In-Reply-To: <20070507142012.GF31253@cs.cas.cz>
References: <20070428114959.GA25723@cs.cas.cz>
	<46337DE1.5030607@statistik.uni-dortmund.de>
	<20070429135347.GA4690@cs.cas.cz> <20070507142012.GF31253@cs.cas.cz>
Message-ID: <Pine.LNX.4.64.0705090628200.6312@gannet.stats.ox.ac.uk>

On Mon, 7 May 2007, Petr Savicky wrote:

> Dear R developers,
>
> I suggest to modify the behaviour of "grep" function with fixed=TRUE option.
>
> Currently, fixed=TRUE implies ignore.case=FALSE (overrides ignore.case=TRUE,
> if set by the user).

As it clearly says it does.

> I suggest to keep ignore.case as set by the user even if fixed=TRUE. Since
> the default of ignore.case is FALSE, this would not change the behaviour
> of grep, if the user does not set ignore.case explicitly.
>
> In my opinion, fixed=TRUE is most useful for suppressing meta-character
> expansion. On the other hand, for a simple word search, ignoring
> case is sometimes useful.

Well, it was written to use in R's own code as a quick way to match a 
fixed sequence of bytes.  It is not suitable for a 'word' search as it 
does not (just) match to words.

> If for some reason, it is better to keep the current behavior of grep, then I
> suggest to extend the documentation as follows:
>
> ORIGINAL:
>   fixed: logical.  If 'TRUE', 'pattern' is a string to be matched as
>          is.  Overrides all conflicting arguments.
>
> SUGGESTED:
>   fixed: logical.  If 'TRUE', 'pattern' is a string to be matched as
>          is.  Overrides all conflicting arguments including ignore.case.

Oh come on, ignore.case clearly conflicts with 'as is'!
Adding unnecessary qualifiers just makes the text harder to read.


I suggest you collaborate with the person who replied that he thought this 
was a good idea to supply patches against the R-devel sources for 
scrutiny.

-- 
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] grep with fixed=TRUE and ignore.case=TRUE
Prof Brian Ripley