[R] Time and xts
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Jan 16 14:03:53 CET 2011
On Sat, Jan 15, 2011 at 11:20 PM, rnick <nikos.rachmanis at gmail.com> wrote:
>
> Hi all,
> I have run into a problem and some help would be highly appreciated.
> I have a .csv with the following columns:
> Date Time Open High Low Close
> 1/2/2005 17:05 1.3546 1.3553 1.3546 1.35495
> 1/2/2005 17:10 1.3553 1.3556 1.3549 1.35525
> 1/2/2005 17:15 1.3556 1.35565 1.35515 1.3553
> 1/2/2005 17:25 1.355 1.3556 1.355 1.3555
> ….
> …..
> 2/13/2006 5:20 1.18895 1.18925 1.18835 1.1885
>
> 1) Without using zoo, xts or any other time series object, I am trying to
> run this code but fails to pass the argument to the function
>
> #n is the length of the series
>
> for (t in seq(from=10,to=n,by=1))
> {
> while (time[t]=='02:00:00')
> {
> entrytrade(t)
> }
> }
> Is this possible to do? If yes, any ideas what I am doing wrong?
Posted code needs to be self contained and reproducible so that others
can copy it from your post, paste it into R and see the same problem
you are seeing. See last line to every r-help message.
>
> 2) I have also tried with xts by creating the object like this
> lines<-data.frame(date,time,open,high,low,close)
> z <- read.zoo(lines, header = TRUE, index = list(1, 2), FUN = function(d,t)
> as.POSIXct(paste(date,time), format = "%m/%d/%Y %H:%M"))
> x<-as.xts(z)
>
> However, I am unable to call just the time and run the above for loop. any
> ideas here?
If by "calling" the time is intended to refer to "extracting" the time
then time(x) gives a vector of times.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list