Hello,

Following a previous post,
http://www.mail-archive.com/r-sig-finance@r-project.org/msg03727.html

I am having trouble with the hours format as it is picked up by the
read.csv() command.

The following data:

"Date","Time","Open","High","Low","Close","Up","Down"
04/27/2012,0930,12.24,12.24,12.24,12.24,0,300
04/27/2012,0930,12.24,12.24,12.24,12.24,0,200

are read as

datain<-read.csv('tick.csv', header=TRUE)

> head(dat)
        Date Time  Open  High   Low Close  Up Down
1 04/27/2012  930 12.24 12.24 12.24 12.24   0  300
2 04/27/2012  930 12.24 12.24 12.24 12.24   0  200


i.e., 0930 becomes 930. How can this be translated to a "proper" time i.e,
9:30 so I can convert the data frame to an XTS object accordingly?

I try to fix it by using  %k below instead of %H  (which also didn't work)

hf<-xts(dat[,6], as.POSIXct(paste(dat[,1], dat[,2]),  format = "%m/%d/%Y
%k%M"))

but I get NAs

> head(hf)
      [,1]
<NA> 12.24
<NA> 12.24
<NA> 12.25
<NA> 12.25
<NA> 12.25
<NA> 12.25

using %I in the format= above also didn't work. I gather that this is not a
timezone problem and has to do with the way the time format is
understood by R when generating a  time index for the XTS object.

Thanks in advance for your time and answers,
Costas
--

	[[alternative HTML version deleted]]

