[R-SIG-Finance] Problems with time format and read.csv()

Dave miniflowtrader at gmail.com
Mon Sep 17 21:15:48 CEST 2012

You will find that using fasttime will make a huge difference in load times
if you are not happy with performance.

parseTickData <- function(inputFile) {
  DAT.list <- scan(file=inputFile,
  index <- fastPOSIXct(paste(DAT.list$Date,DAT.list$Time),"GMT")
  DAT.xts <-
  DAT.xts <- make.index.unique(DAT.xts)

Your data must be in the format:


-----Original Message-----
From: r-sig-finance-bounces at r-project.org
[mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Costas Vorlow
Sent: Monday, September 17, 2012 2:14 PM
To: r-sig-finance at r-project.org
Subject: [R-SIG-Finance] Problems with time format and read.csv()


Following a previous post,

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

The following data:


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

but I get NAs

> head(hf)
<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]]

R-SIG-Finance at r-project.org mailing list
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions
should go.

More information about the R-SIG-Finance mailing list