Skip to content
Prev 312285 / 398506 Next

hhmm time format, strptime and %k

Hi,
You could also use:
x$Time<-sprintf("%04d",x$Time)
?res<-xts(x[,-c(1,2)],order.by=as.POSIXct(paste(x[,1],x[,2],sep=" "),format="%m/%d/%Y %H%M"))
res
#????????????????????? Open?? High??? Low? Close????? Up??? Down? Volume
#2012-11-19 09:35:00 137.89 138.06 137.82 138.05 3202541 3013215?????? 0
#2012-11-19 09:40:00 138.04 138.40 138.02 138.38 2549660 2107595 4657255
#2012-11-19 09:45:00 138.38 138.40 138.18 138.19 1627379 1856318 3483697
#2012-11-19 09:50:00 138.20 138.32 138.20 138.30 1046133? 896423 1942556
#2012-11-19 09:55:00 138.30 138.49 138.30 138.41 1287646? 961604 2249250
#2012-11-19 10:00:00 138.41 138.49 138.39 138.43? 806043? 731641 1537684

A.K.




----- Original Message -----
From: jim holtman <jholtman at gmail.com>
To: Costas Vorlow <costas.vorlow at gmail.com>
Cc: r-help at r-project.org
Sent: Wednesday, November 28, 2012 4:33 PM
Subject: Re: [R] hhmm time format, strptime and %k

Try this? (prepend leading zero in some cases)
+ 1 11/19/2012? 935 137.89 138.06 137.82 138.05 3202541 3013215? ? ?  0
+ 2 11/19/2012? 940 138.04 138.40 138.02 138.38 2549660 2107595 4657255
+ 3 11/19/2012? 945 138.38 138.40 138.18 138.19 1627379 1856318 3483697
+ 4 11/19/2012? 950 138.20 138.32 138.20 138.30 1046133? 896423 1942556
+ 5 11/19/2012? 955 138.30 138.49 138.30 138.41 1287646? 961604 2249250
+ 6 11/19/2012 1000 138.41 138.49 138.39 138.43? 806043? 731641 1537684"
+? ?  , header = TRUE
+? ?  , as.is = TRUE
+? ?  )
? ? ? ? Date Time?  Open?  High? ? Low? Close? ? ? Up? ? Down? Volume
? ? ? ? ?  newTime
1 11/19/2012 0935 137.89 138.06 137.82 138.05 3202541 3013215? ? ?  0
2012-11-19 09:35:00
2 11/19/2012 0940 138.04 138.40 138.02 138.38 2549660 2107595 4657255
2012-11-19 09:40:00
3 11/19/2012 0945 138.38 138.40 138.18 138.19 1627379 1856318 3483697
2012-11-19 09:45:00
4 11/19/2012 0950 138.20 138.32 138.20 138.30 1046133? 896423 1942556
2012-11-19 09:50:00
5 11/19/2012 0955 138.30 138.49 138.30 138.41 1287646? 961604 2249250
2012-11-19 09:55:00
6 11/19/2012 1000 138.41 138.49 138.39 138.43? 806043? 731641 1537684
2012-11-19 10:00:00

        
On Wed, Nov 28, 2012 at 4:02 PM, Costas Vorlow <costas.vorlow at gmail.com> wrote: