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.
Dimitris Rizopoulos
2012-Feb-10 14:29 UTC
[R] Find interval between numbers in list or vector
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/
Thanks, it is exactly the function that I needed. -- View this message in context: http://r.789695.n4.nabble.com/Find-interval-between-numbers-in-list-or-vector-tp4376115p4378473.html Sent from the R help mailing list archive at Nabble.com.