1+pmax(abs(row(z)-3),abs(col(z)-3))
?row ?col ?pmax for details.
Bert Gunter
Genentech Nonclinical Statistics
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
Behalf Of Muhammad Rahiz
Sent: Wednesday, April 14, 2010 9:44 AM
To: r-help at r-project.org
Subject: [R] array manipulation
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
______________________________________________
R-help at r-project.org 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.