[Kst] ctime display format

Dirk Eddelbuettel edd at debian.org
Sat Apr 22 17:23:30 CEST 2006


Hi kst'ers,

After some minor wrestling, I managaed to import a large-ish (approx 400k
lines) data set of fairly high-frequency observations from a text file. 

Using ctime was the preferred option -- but I would like kst to use the fact
that this is C time ... and let me display with strftime() variant :)

As an example, consider what GNU R (from where I exported the data) does.  In
R I have a data object that is indexed with a POSIXt / POSIXct type:

> index(Z)[1:4]
[1] "2006-03-02 07:00:00.786 CST" "2006-03-02 07:00:00.839 CST"
[3] "2006-03-02 07:00:00.971 CST" "2006-03-02 07:00:00.973 CST"
> class(index(Z)[1:4])
[1] "POSIXt"  "POSIXct"

for which the default display can even be told to respect milliseconds (as of
R 2.3.0, to be released Monday) as I did here (the default is just seconds).

I can then format these POSIXt types any way I like using the usual C library
converters (and %OS instead of %S gets me subsecond resolution):

> format(index(Z)[1:4], "%d-%b %H:%M:%OS")
[1] "02-Mar 07:00:00.786" "02-Mar 07:00:00.839" "02-Mar 07:00:00.971"
[4] "02-Mar 07:00:00.973"

or I can simply convert them to C time, which is what I did to get the data
into kst:

> as.numeric((index(Z)[1:4]))
[1] 1141304401 1141304401 1141304401 1141304401
> print(as.numeric((index(Z)[1:4])), digits=14)
[1] 1141304400.786 1141304400.839 1141304400.971 1141304400.973

Now, is there a way to have kst convert these numerics back into 'human
readable' time for display purposes?

Regards,  Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison


More information about the Kst mailing list