Re: [R] return unique values from date/time class object

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 15 Aug 2005 - 18:39:43 EST

On Mon, 15 Aug 2005, McClatchie, Sam (PIRSA-SARDI) wrote:

> Background:
> OS: Linux Mandrake 10.1
> release: R 2.0.0

Time for an update.

> editor: GNU Emacs 21.3.2
> front-end: ESS 5.2.3
> ---------------------------------
> Colleagues
>
> I have a wind speed time series with a normal frequency distribution and a
> spike in the 5 metres/second bin. The most likely explanation is that the
> instrument was returning duplicate values at this speed. To check this, I
> want to extract all the unique times from the series. However, unique()
> works with vectors and the object is POSIXt class. I've looked for a similar
> function to unique() that will work with this class, but have failed to find
> one.

foo[!duplicated(unclass(foo))]

works, for POSIXct (POSIXt is a virtual class covering that and POSIXlt: for the latter convert to POSIXct).

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Aug 15 18:46:23 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:19:49 EST