[R] How to compare a value in a matrix with its neighbours

From: Simon Parker <simon_ecc_at_yahoo.co.uk>
Date: Thu, 08 May 2008 13:04:12 +0100 (BST)


I'm trying to compare a value in a 2-D matrix with its 4 neighbours.

I think I could use row() and col() and use x[row(x)] and x[row(x)-1] etc..., but I can't see how it would work.

Also, any way of having a matrix fill itself with its own coordinates would also work.

Any ideas please.

Simon Parker
Imperial College        

A Smarter Email.

        [[alternative HTML version deleted]]

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. Received on Thu 08 May 2008 - 12:22:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 08 May 2008 - 13:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive