[R] problem with indexing a zoo object

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Wed Nov 29 22:49:54 CET 2006


My problem is the following : I create 2 zoo objects and then I try to
subset one of them using logic. indicesthatpass is a vector of trues and
falses but when I send it into bckret, it returns an empty bckret.
Obviously it has something to do with bckret being a zoo object and if I
do the same subsctripting off of coredata(bckret), I'm confident it will
work. But, I need to keep the minute days of bckret.

So, I have two questions :

1) is there a way around this ? 

2) even if the answer to 1) is yes, there could be some other way better
than what I am doing ? It took me a while to even get to this point
because I was taking is.infinite of fwdret and abs of bckret rather than
their respective coredatas and that was really causing a mess because of
the different indexing that was getting returned. 

Thanks.


# SET SEED
set.seed(1)

# CREATE  2 ZOO OBJECTS, bckkret and fwdret OF MINUTE DATA OVER THE
WHOLE DAY

x.date<-as.Date(paste(2003,01,01,sep="-"))
allminutes<-as.POSIXct(format(x.date,"%Y-%m-%d")) + 60 * seq(1, 24 * 60)
bckret<-zoo(matrix(abs(rnorm(1440)),nc=1),allminutes)
fwdret<-zoo(matrix(abs(rnorm(1440)),nc=1),allminutes)

indicesthatpass<-!is.infinite(coredata(fwdret)) &
!(abs(coredata(bckret)) > 1.00)

#SUBSET bckret 

bckret<-bckret[indicesthatpass,drop=FALSE]
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}



More information about the R-help mailing list