Re: [R] Help with programming a tricky algorithm

2012-10-22 Thread Andrew Crane-Droesch
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(

Re: [R] Help with programming a tricky algorithm

2012-10-22 Thread Rui Barradas
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

Re: [R] Help with programming a tricky algorithm

2012-10-22 Thread Andrew Crane-Droesch
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

Re: [R] Help with programming a tricky algorithm

2012-10-21 Thread Rui Barradas
3 c1 x3 1 #44 2 4 c1 x4 1 #55 2 4 c2 x5 1 #66 2 5 c2 x6 1 #77 3 5 c3 x7 1 #88 3 5 c3 x8 NA #9 9 3 5 c3 x9 NA - Original Message - From: Andrew Crane-Droesch To: r-

Re: [R] Help with programming a tricky algorithm

2012-10-21 Thread arun
c1   x2  1 #3    3  1  3  c1   x3  1 #4    4  2  4  c1   x4  1 #5    5  2  4  c2   x5  1 #6    6  2  5  c2   x6  1 #7    7  3  5  c3   x7  1 #8    8  3  5  c3   x8 NA #9    9  3  5  c3   x9     NA - Original Message - From: An

Re: [R] Help with programming a tricky algorithm

2012-10-21 Thread Rui Barradas
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

Re: [R] Help with programming a tricky algorithm

2012-10-20 Thread Rui Barradas
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)

[R] Help with programming a tricky algorithm

2012-10-20 Thread Andrew Crane-Droesch
Hi All, I'm a little stumped by the following problem. I've got a dataset with the following structure: idxyixiycountry(other variables) 111c1x1 212c1x2 313c1x3 ... .

Re: [R] help with programming

2011-11-07 Thread David Winsemius
On Nov 7, 2011, at 6:30 AM, Jing Tian wrote:  Dear moderators, Please help me encode the program instructed by follows. Thank u! Apply the methods introduced in Sections 4.2.1 and 4.2.2, say the rank-based variable selection and BIC criterions, to the Boston housing data.  The Bosto

Re: [R] help with programming

2011-11-07 Thread Joshua Wiley
Hi J. Tian, This list is not for helping with homework problems. Please see your instructor or teacher for assistance as it is what she or he is paid for. Cheers, Josh On Mon, Nov 7, 2011 at 3:30 AM, Jing Tian wrote: >> >>  > > Dear moderators, > > Please help me encode the program instructe

[R] help with programming

2011-11-07 Thread Jing Tian
> >  Dear moderators, Please help me encode the program instructed by follows. Thank u! Apply the methods introduced in Sections 4.2.1 and 4.2.2, say the > rank-based variable selection and BIC criterions, to the Boston housing > data. >  The Boston housing data contains 506 observations,