[R] Removing

David Winsemius dwinsemius at comcast.net
Thu Mar 12 20:02:09 CET 2009


True, I suppose. The specification from Ma could have been more  
explicit. Should she want to only have duplicates in sequence, then  
perhaps the use of construction within the rle function would be useful.

act2[ act2$Rep[-1] != act2$Rep[-length(act2$Rep)], ]

          Date    Dtime Hour Min Second               Rep
51 2006-02-22 14:52:18   14  52     18  useractivity_act
57 2006-02-22 14:52:51   14  52     51                 4
58 2006-02-22 14:52:52   14  52     52                 3
60 2006-02-22 14:54:42   14  54     42 useractivity_idle

Which turns out on examination to be isomorphic to Gabor's earlier  
efforts.
-- 
David Winsemius


On Mar 12, 2009, at 2:31 PM, Patrick Burns wrote:

> Simpler, but maybe wrong.  Not duplicated
> was my first response as well, but then I began
> wondering if the question implied globally
> duplicated or duplicated within subgroups.
>
>
> Patrick Burns
> patrick at burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of "The R Inferno" and "A Guide for the Unwilling S User")
>
> David Winsemius wrote:
>> Much simpler would be:
>>
>> act2[!duplicated(act2$Rep),]   #use the negation of the duplicated  
>> function on $Rep and indexing
>>
>>         Date    Dtime Hour Min Second               Rep
>> 51 2006-02-22 14:52:18   14  52     18  useractivity_act
>> 52 2006-02-22 14:52:18   14  52     18                 4
>> 58 2006-02-22 14:52:52   14  52     52                 3
>> 60 2006-02-22 14:54:42   14  54     42 useractivity_idle
>>
>> Cannot reproduce the blank line though.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list