[R] Find interval between numbers in list or vector
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Fri Feb 10 15:29:59 CET 2012
Have a look at function diff(), e.g.,
diff(c(1,4,10,30))
I hope it helps.
Best,
Dimitris
On 2/10/2012 1:33 PM, alend wrote:
> hi,
>
> I have a vector as follow:
>
> myVec = c(1,4,10,30)
>
> How can I get a vector that show the interval of the numbers.
>
> I need to get this result:
>
> distance
>> 3,6,20
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Find-interval-between-numbers-in-list-or-vector-tp4376115p4376115.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/
More information about the R-help
mailing list