Thank you all!

This looks like the fastest solution, N being big and my machine slow  
I'll go for this one.

Thanks,

baptiste

On 22 Jul 2007, at 12:54, Gavin Simpson wrote:

>>
>> 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).
>
> This does what you want:
>
> foo <- function(N) {
>    reps <- 2*N+1
>    matrix(c(rep(-N:N, each = reps), rep(-N:N, times = reps)),
>           nrow = 2, byrow = TRUE)
> }

______________________________________________
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