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.steele@gmail.com>wrote:

> 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       x[i+1]-x[i]
> ---    ---------------
> 14
> 14      0
> 75      61
> 136     61
> 197     61
> 236     39
> 253     17
> 310     57
> 323     13
> 355     32
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]


