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

Patrick Burns pburns at pburns.seanet.com
Sat Aug 5 21:38:43 CEST 2006


I propose that a 'value' argument be added to
'lower.tri' and 'upper.tri'.  This is analogous to
the 'value' argument of 'grep'.

Something like the following should work:

 > upper.tri
function (x, diag = FALSE, value = FALSE)
{
    x <- as.matrix(x)
    if (diag)
        ans <- row(x) <= col(x)
    else ans <- row(x) < col(x)
    if(value) x[ans] else ans
}
<environment: namespace:base>


Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")



More information about the R-devel mailing list