[R] array manipulation

Muhammad Rahiz muhammad.rahiz at ouce.ox.ac.uk
Wed Apr 14 18:44:00 CEST 2010


Hello listeRs,

I'm trying to make a square radius around a given reference point. So 
given the following array, how can I manipulate it so that

x0 <- array(1,dim=c(5,5))
x0

1 1 1 1 1
1 1 1 1 1
1 1 *1* 1 1
1 1 1 1 1
1 1 1 1 1

becomes

into

3 3 3 3 3
3 2 2 2 3
3 2 *1* 2 3
3 2 2 2 3
3 3 3 3 3

Thanks.

Muhammad



More information about the R-help mailing list