Skip to content

loop

2 messages · Omar Lakkis, Brian Ripley

#
Rather than using a loop, how can I remove all consequentially
repeated values as in this example?
I am guessing using diff would help but not quite sure how.
date          f  
1 1999-01-01 1
2 1999-01-02 1
3 1999-01-03 1
4 1999-01-04 2
5 1999-01-05 2
date          f
1 1999-01-01 1
4 1999-01-04 2
#
On Wed, 18 May 2005, Omar Lakkis wrote:

            
I am not sure I see the pattern, but it might be one of

s[!duplicated(s$f), ]

s[diff(c(0, s$f)) != 0, ]

(which differ).