From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>

Date: Tue 07 Sep 2004 - 18:16:51 EST

Date: Tue 07 Sep 2004 - 18:16:51 EST

On Sat, 4 Sep 2004 tlumley@u.washington.edu wrote:

> I have made the 3-d case do the same as the vector case, which is what the

*> C code clearly intended (a goto label was in the wrong place).
**>
**> This leaves the bigger question of the right thing to do. I note that data
**> frames give an error when any indices are NA.
*

One case is unambiguous and common:

x[ind] <- val

where `val' is of length one. I've written code to ban all other subassignments involving NAs. Once I fixed occurrences in R itself (notably in ifelse), only three problems remain in tests over the CRAN packages

< Running examples in ape-Ex.R failed.

< > ### * popsize

area[a == 0] <- stepfunction[a == 0]

< Running examples in RandomFields-Ex.R failed.
< > ### * ShowModels

expr[pmatch(covlist, namen)] <- exprlist

< Running examples in sm-Ex.R failed.

< > ### * sm.sphere

z[xyzok < 0] <- (za - zb)[xyzok < 0]

The first and third are a typical usage, where R makes more sense than S. [Worryingly, sm was written for S-PLUS and would seem to be incorrect there.]

So in R 2.0.0 we will have

\section{NAs in indexing}{

When subscripting, a numerical, logical or character \code{NA} picks
an unknown element and so returns \code{NA} in the corresponding
element of a logical, integer, numeric, complex or character result,
and \code{NULL} for a list.

When replacing (that is using subscripting on the lhs of an assignment) \code{NA} does not select any element to be replaced. As there is ambiguity as to whether an element of the rhs should be used or not (and \R handled this inconsistently prior to \R 2.0.0), this is only allowed if the rhs value is of length one (so the two interpretations would have the same outcome). }

-- Brian D. Ripley, ripley@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 ______________________________________________ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-develReceived on Tue Sep 07 18:20:37 2004

*
This archive was generated by hypermail 2.1.8
: Wed 03 Nov 2004 - 22:45:13 EST
*