Hi Rui,
Thanks for the quick reply! It was my mistake not to notice $country in
thr fourth line of your code. I went back and changed it to $name, and
got the following output when I mapped the borders:
http://i.imgur.com/DQ3IB.png
Here is the output of your function:
1> exmpl <- sub[, c(
Hello,
In your original post, there was a column named 'country', it now seems
to be 'name', therefore my function shouldn't work. To see the output of
head(9 is helpfull but the better way is dput(). Try the following:
exmpl <- sub[, c("name", "idxy", "ix", iy")]
dput( head(exmpl, 30) ) # p
Rui,
Thanks a lot for your help. Unfortunately this doesn't work though:
1> is.border <- function(idx, DF){
1+ i1 <- DF$ix %in% (DF$ix[idx] + c(-1, 1)) & DF$iy == DF$iy[idx]
1+ i2 <- DF$iy %in% (DF$iy[idx] + c(-1, 1)) & DF$ix == DF$ix[idx]
1+ any(DF$country[idx] != DF$country[i1 | i
Hello,
Thanks for the dataset, Arun, I could test my function and it was still
wrong (apologies to the op).
Now I think I've got it.
is.border <- function(idx, DF){
i1 <- DF$ix %in% (DF$ix[idx] + c(-1, 1)) & DF$iy == DF$iy[idx]
i2 <- DF$iy %in% (DF$iy[idx] + c(-1, 1)) & DF$ix == DF$ix[
HI,
I am not sure whether this is what you want.
Mydata<-read.table(text="
idxy ix iy country col5
1 1 1 c1 x1
2 1 2 c1 x2
3 1 3 c1 x3
4 2 4 c1 x4
5 2 4 c2
Hello,
The function in my previous post gives neighbours in north, south, east
and west but also the corners, for a total of 8, not 4, neighbours.
Corrected:
is.border <- function(idx, DF){
i1 <- DF$ix %in% DF$ix[idx] + c(-1, 1) & DF$iy == DF$iy[idx]
i2 <- DF$iy %in% DF$iy[idx] + c(-1
Hello,
You should post a data example with ?dput. If your dataset is named
MyData, use
dput( head(MyData, 30) ) # paste the output of this in a post
Anyway, I believe the following function might do what you want. It's
untested, though. (Your example dataset is usefull but could be better)
7 matches
Mail list logo