Skip to content
Prev 308674 / 398503 Next

Help with programming a tricky algorithm

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("name", "idxy", "ix", "iy")]
1> dput( head(exmpl, 30) )
structure(list(name = structure(c(1L, 6L, 6L, 1L, 5L, 6L, 1L,
1L, 1L, 1L, 1L, 6L, 1L, 1L, 1L, 5L, 1L, 6L, 1L, 5L, 6L, 1L, 1L,
3L, 1L, 6L, 1L, 6L, 1L, 3L), .Label = c("benin", "burkinafaso",
"ghana", "niger", "nigeria", "togo"), class = "factor"), idxy = c(1892L,
492L, 1052L, 2732L, 3712L, 842L, 2522L, 3292L, 3012L, 3432L,
2172L, 772L, 2242L, 3152L, 1402L, 3852L, 1612L, 422L, 2662L,
3642L, 702L, 2942L, 2802L, 212L, 1682L, 1122L, 1962L, 1192L,
2452L, 142L), ix = c(27, 7, 15, 39, 53, 12, 36, 47, 43, 49, 31,
11, 32, 45, 20, 55, 23, 6, 38, 52, 10, 42, 40, 3, 24, 16, 28,
17, 35, 2), iy = c(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, 1, 1, 1, 1, 1)), .Names = c("name",
"idxy", "ix", "iy"), row.names = c(NA, 30L), class = "data.frame")

I must say that I am impressed by the response of the community on this 
mailing list.  I look forward to getting better at R such that I can be 
more useful to others myself!

Best,
Andrew
On 10/22/2012 08:33 AM, Rui Barradas wrote: