[R] its does not recognize POSIXct w/ both time and Date?

Gabor Grothendieck ggrothendieck at gmail.com
Mon Nov 5 22:18:49 CET 2007


On Nov 5, 2007 3:50 PM, B. Bogart <bbogart at sfu.ca> wrote:
> Hello all,
>
> I'm getting much further with my time-series work, but still getting
> into some problems.
>
> I'm using POSIXct time format with both date and time.
>
> I'd like to use that in an its object but It seems its only processes
> the date part of the POSIX time stamps:
>
> BMU_its_data <-  its(data[BMUindex,2-4],dates=data[BMUindex,1])
> Error in `row.names<-.data.frame`(`*tmp*`, value = c("2007-10-31",
> "2007-10-31",  :
>
>
> The first column of the data is certainly correct, with both date and time:
>
>  > summary(data[BMUindex,1])
>                     Min.                   1st Qu.
> Median
> "2007-10-31 07:00:00 UTC" "2007-11-01 07:00:00 UTC" "2007-11-03 07:00:00
> UTC"
>                     Mean                   3rd Qu.
> Max.
> "2007-11-02 21:44:12 UTC" "2007-11-04 07:00:00 UTC" "2007-11-05 08:00:00
> UTC"
>
> Perhaps the functions used in its are unable to see the time field. I
> noticed that using unique() on the same data gives me only 6 different
> values, one for each day, with the times ignored.
>
> Is there any time format I can use in R (through its or zoo or fCalendar
> or anything) that allows me to use tools such as unique() and so on and
> have the times (not only dates) considered?
>
> I've chosen its because it seems to have pretty good ts specific
> plotting stuff in there, but I'd be willing to use anything that allows
> me to work with my POSIX dates down to the second. (or even msec)
>

Please provide reproducible examples as asked in last line on every
message to r-help.

Its unlikely that 'its' ignores date fields but perhaps this will get
you going.
Each of these gives the first value and its time for each value that occurs
in the series:

> # its
> library(its)
> ii <- its(rep(1:2, 5), Sys.time() + 1:10)
> ii[!duplicated(ii)]
An object of class "its"
         1
20071105 1
20071105 2
Slot "dates":
[1] "2007-11-05 16:03:09 Eastern Standard Time"
[2] "2007-11-05 16:03:10 Eastern Standard Time"

> # zoo
> library(zoo)
> z <- zoo(rep(1:2, 5), Sys.time() + 1:10)
> z[!duplicated(z)]
2007-11-05 16:03:10 2007-11-05 16:03:11
                  1                   2



More information about the R-help mailing list