[R-SIG-Finance] millisec timestamps for rows of xts/zoo object

Dirk Eddelbuettel edd at debian.org
Sun Jun 5 19:57:34 CEST 2011


On 5 June 2011 at 19:41, Ulrich Staudinger wrote:
| Misunderstanding ...
| 
| rowse[1]> options(digits.secs=6)
| Browse[1]> head(tempBs)
|                         ..1   ..2 ..3 pnlSlice
| 2011-06-03 13:32:24.975 242 99125   1      -75
| 2011-06-03 13:32:55.036 242 99100  -1      -25
| 2011-06-03 13:36:10.490 242 98850  -1      -50
| 2011-06-03 13:36:59.064 242 98775   2       25
| 2011-06-03 13:38:21.795 242 98550  -2     -200
| 2011-06-03 13:40:01.725 242 98825   1     -450
| Browse[1]>
| 
| 
| that's not what I need. A bit of digging revealed:
| 
| Browse[1]> as.double(as.POSIXct("2011-06-03 13:32:24"))
| [1] 1307100744
| Browse[1]>
| 
| I would like to get the timestamp instead of a date string ...
| some matrix where the first column contains the timestamp in milliseconds
| since epoch start ...

Just use as.numeric() on your POSIXct object:

R> print( as.numeric( Sys.time() ), digits=20 )
[1] 1307296635.9376249313
R> 


Dirk

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com



More information about the R-SIG-Finance mailing list