[Rd] proposal for lower.tri and upper.tri value argument

Gabor Grothendieck ggrothendieck at gmail.com
Sun Aug 6 18:07:42 CEST 2006


On 8/6/06, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> Is there a case to be made for this?  If so, where is it?
>
> (I don't find x[lower.tri(x)] harder to write than lower.tri(x,
> value=TRUE), and wonder why you do?

The reasons are

1. x might be the result of an expression.  Without value=
one must store the result of that expression in a variable, x, first:

   x <- outer(1:6, 1:6, "+")
   x[lower.tri(x)]

but with the proposed value= argument one could just use function
composition:

   lower.tri(outer(1:6, 1:6, "+"), value = TRUE)

2. the whole object approach of R encourages working with the objects
themselves rather than indexes and value= is consistent with that.



More information about the R-devel mailing list