Skip to content
Back to formatted view

Raw Message

Message-ID: <43006A15.8845.3104E3@localhost>
Date: 2005-08-15T08:10:29Z
From: PIKAL Petr
Subject: return unique values from date/time class object
In-Reply-To: <BEA6A7E18959A04385DC14D24619F89F01D73C1D@sagemsg0008.sagemsmrd01.sa.gov.au>

Hi Sam

It works for me:

ss<-Sys.time()
sss<-rep(ss,5)
ss<-Sys.time()
sss<-c(sss,ss)
> sss
[1] "2005-08-15 10:04:02 St??edn?? Evropa (letn?? ??as)" "2005-08-15 
10:04:02 St??edn?? Evropa (letn?? ??as)"
[3] "2005-08-15 10:04:02 St??edn?? Evropa (letn?? ??as)" "2005-08-15 
10:04:02 St??edn?? Evropa (letn?? ??as)"
[5] "2005-08-15 10:04:02 St??edn?? Evropa (letn?? ??as)" "2005-08-15 
10:04:35 St??edn?? Evropa (letn?? ??as)"

# six values but only 2 different

> unique(sss)
[1] "2005-08-15 10:04:02 St??edn?? Evropa (letn?? ??as)" "2005-08-15 
10:04:35 St??edn?? Evropa (letn?? ??as)"

# 2 values

> str(sss)
'POSIXct', format: chr [1:6] "2005-08-15 10:04:02" "2005-08-15 
10:04:02" "2005-08-15 10:04:02" "2005-08-15 10:04:02" "2005-
08-15 10:04:02" ...

# posix format as well

HTH
Petr





On 15 Aug 2005 at 16:57, McClatchie, Sam (PIRSA-SARDI) wrote:

> Background:
> OS: Linux Mandrake 10.1
> release: R 2.0.0
> 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.
> 
> Any suggestions?
> 
> Thanks
> 
> Sam
> ----
> Sam McClatchie,
> Biological oceanography 
> South Australian Aquatic Sciences Centre
> PO Box 120, Henley Beach 5022
> Adelaide, South Australia
> email <mcclatchie.sam at saugov.sa.gov.au>
> Cellular: 0431 304 497 
> Telephone: (61-8) 8207 5448
> FAX: (61-8) 8207 5481
> Research home page <http://www.members.iinet.net.au/~s.mcclatchie/>
> 
>                    /\
>       ...>><xX(??> 
>                 //// \\\\
>                    <??)Xx><<
>               /////  \\\\\\
>                         ><(((??> 
>   >><(((??>   ...>><xX(??>O<??)Xx><<
> 
> ______________________________________________
> R-help at 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

Petr Pikal
petr.pikal at precheza.cz