[R] Finding the distance between ordered integers

2009-01-22 Thread Dale Steele
I'm stuck on how best to of find the distance between ordered integers (presented below as a birthday problem). Given the vector x, how do I most efficiently generate the vector x[i+1] - x[i]? Thanks. --Dale For example... set.seed(555) x - sample(1:365, 10, replace=TRUE) x - sort(x) x

Re: [R] Finding the distance between ordered integers

2009-01-22 Thread Jorge Ivan Velez
Dear Dale, Try this: set.seed(555) x - sample(1:365, 10, replace=TRUE) x - sort(x) diff(x) HTH, Jorge On Thu, Jan 22, 2009 at 10:07 AM, Dale Steele dale.w.ste...@gmail.comwrote: I'm stuck on how best to of find the distance between ordered integers (presented below as a birthday problem).