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

Patrick Burns pburns at pburns.seanet.com
Sun Aug 6 18:35:48 CEST 2006


Gabor came close to the situation I had yesterday
that prompted me to write a local version of 'lower.tri'.
It was approximately:

x[sub, sub][lower.tri(x[sub,sub])]

Pat

Gabor Grothendieck wrote:

> 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