Hi,

I want to make the following array of numbers:

-3 -3 -3 -3 -3 -3 -3 -2 -2 -2 -2 -2 -2 -2 ...  3  3  3  3  3  3  3
-3 -2 -1  0  1  2  3 -3 -2 -1  0  1  2  3 ... -3 -2 -1  0  1  2  3

(3 would be N, a painful example to type number).

Here is my dirty attempt to do it,

> N<-3
>
> x<-c(-N:N)
>
> rj<-rbind(matrix(outer(matrix(1,1,2*N+1),x),nrow=1),rep(x,2*N+1))
>

It sort of works, but I'd like some advice on how to do it properly  
as I'm very new to R and N may be big at some point.

Thanks,

baptiste

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to