[R-sig-finance] dates and times on Windows for fMetrics

Tom Mulholland tmulholland at bigpond.com
Sun Dec 12 11:14:23 CET 2004


First things first

R       "R version 2.0.1, 2004-11-15"
OS.type "windows"
GUI     "Rgui"

I thought that I had the time and date stuff nearly under control. I 
don't get the ubiquitous "GMT" warning although I'm not sure that the 
way I have done it is correct. I use a batch file to invoke R

set TZ=GMT
rgui.exe

I have a dataset that I use called tempdata

 > str(tempdata)
`data.frame':   300 obs. of  7 variables:
  $ date     : chr  "2003/10/09" "2003/10/10" "2003/10/13" "2003/10/14" ...
  $ Open     : num  1.27 1.25 1.27 1.29 1.27 1.28 1.32 1.35 1.35 1.34 ...
  $ High     : num  1.28 1.28 1.29 1.29 1.29 1.31 1.35 1.37 1.37 1.34 ...
  $ Low      : num  1.25 1.25 1.27 1.27 1.27 1.28 1.31 1.32 1.33 1.32 ...
  $ Close    : num  1.25 1.27 1.28 1.27 1.28 1.31 1.35 1.35 1.34 1.33 ...
  $ Volume   : int  152810 111338 243843 180211 159147 386021 270289 
690343 574630 314740 ...
  $ dateposix:`POSIXct', format: chr  "2003-10-09" "2003-10-10" 
"2003-10-13" "2003-10-14" ...

I use the POSIXct in my own home-made plots. In playing with Fmetrics I 
naturaly wanted to create a time series

This works
ts = timeSeries(tempdata[,2:6], charvec = tempdata[,1],format = 
"%Y/%m/%d",FinCenter = "Australia/Sydney")

Although if I set myFinCenter to "Australia/Perth" it fails. (See below 
for structure)

while
ts = timeSeries(tempdata[,2:6], charvec = tempdata[,1],format = 
"%Y/%m/%d",FinCenter = "Australia/Perth") fails with

Error in if (timeTest == 0) iso.format = "%Y-%m-%d" :
         missing value where TRUE/FALSE needed

Ive looked at the function but I'm missing something.

Any ideas would be much appreciated


 > str(ts)
Formal class 'timeSeries' [package "fBasics"] with 7 slots
   ..@ Data         : num [1:300, 1:5] 1.27 1.25 1.27 1.29 1.27 1.28 
1.32 1.35 1.35 1.34 ...
   .. ..- attr(*, "dimnames")=List of 2
   .. .. ..$ : chr [1:300] "2003-10-09 10:00:00" "2003-10-10 10:00:00" 
"2003-10-13 10:00:00" "2003-10-14 10:00:00" ...
   .. .. ..$ : chr [1:5] "TS.1" "TS.2" "TS.3" "TS.4" ...
   ..@ positions    : chr [1:300] "2003-10-09 10:00:00" "2003-10-10 
10:00:00" "2003-10-13 10:00:00" "2003-10-14 10:00:00" ...
   ..@ format       : chr "%Y-%m-%d %H:%M:%S"
   ..@ FinCenter    : chr "Australia/Sydney"
   ..@ units        : chr [1:5] "TS.1" "TS.2" "TS.3" "TS.4" ...
   ..@ title        : chr "Time Series Object"
   ..@ documentation: chr "Created at Australia/Sydney 2004-12-12 19:52:35"



More information about the R-sig-finance mailing list