Hi All,

I'm a little stumped by the following problem. I've got a dataset with the following structure:

idxy    ix    iy    country    (other variables)
1        1    1    c1            x1
2        1    2    c1            x2
3        1    3    c1            x3
.        .        .       .            .

3739    55    67    c7        x3739
3740    55    68    c7        x3740

where ix and iy are interger-valued indices of the actual x and y coordinates for the gridded data

I want to define a "border" variable that equals 1 if the cell north, east, west, or south of it has a different value of the country variable. So, for the row with idxy = 1, border would equal 1 if there is any idxy with country !=c1 and ix = 2 (or zero) or iy = 2 (or zero).

Any thoughts?

Thanks!
Andrew

______________________________________________
R-help@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.

Reply via email to