How to compare a value in a matrix with its neighbours

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to compare a value in a matrix with its neighbours

ppaarrkk
Hello.

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]]

______________________________________________
[hidden email] 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.