Skip to content

generating a sequence

2 messages · Brian Ripley, Jonathan Rougier

#
I am a bit puzzled here. Why is that n=5 not n=4? Anyway, try

A <- matrix(1, n-1, n-1)
rA <- row(A)
rA[rA + col(A) <= n]
#
On Tue, 21 Dec 1999, Prof Brian Ripley wrote:

            
Or, in the festive spirit,

n <- 5
rA <- outer(1:n, 1:n, "-")
rA[rA>=1]

Cheers, Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE

"[B]egin upon the precept ... that the things we see are to be 
 weighed in the scale with what we know"  (Meredith, 1879, The Egoist)

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._