I want to run some 1 minute data I get from a trading app through an R program I've written. So far all of my xts objects have just been daily bars from Yahoo, etc. How do I create the time part of the xts index? Note that Date & Time are in the first 2 columns. It is possible that there will be missing dates, it's pretty much guaranteed there will be missing minutes. There should not be any duplicates. (I'll check for that myself)
Thanks
library(timeDate)
TestData = structure(list(X = 1:6, Date = structure(c(1L, 1L, 1L, 1L, 1L,
1L), .Label = "07/01/1998", class = "factor"), Time = structure(1:6, .Label = c("06:31",
"06:34", "06:35", "06:36", "06:38", "06:39"), class = "factor"),
Open = c(114.06, 114.11, 114.06, 114.09, 114.09, 114.06),
High = c(114.06, 114.13, 114.13, 114.09, 114.09, 114.13),
Low = c(114, 114.06, 114.06, 114.03, 114.06, 114.06), Close = c(114,
114.06, 114.13, 114.03, 114.06, 114.13), Volume = c(257600L,
24400L, 2500L, 900L, 3000L, 16700L)), .Names = c("X", "Date",
"Time", "Open", "High", "Low", "Close", "Volume"), class = "data.frame", row.names = c(NA,
-6L))
MyDates = as.Date(TestData$Date,format = "%m/%d/%Y")
MyTimes = as.vector(TestData$Time)
MyIndexes = timeDate(paste(MyDates, MyTimes), format = "%Y-%m-%d %H:%M", zone="UTC")
NewData = xts(TestData[,3:7], order.by = MyIndexes)
is.xts(NewData)