[R-SIG-Finance] date to index

me me at censix.com
Mon Apr 30 20:22:01 CEST 2012


#Assuming you are interested in the date '2007-01-08'
#and lets say GOOG is your series

require(quantmod)
getSymbols('GOOG')

#This would be one way to get the row(index)number corresponding to
your date

which( index(GOOG)==index(GOOG['2007-01-08']) )

#Cheers, Soren


On Mon, 30 Apr 2012 12:42:11 -0500
Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:

> It's not clear to me what you're trying to do.  An example would help.
> 
> My guess is that you're looking for something like this:
> x <- xts(1:10, Sys.Date()-10:1)
> rbind(x, xts(NA_integer_,Sys.Date()-11))
> 
> Best,
> --
> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
> 
> R/Finance 2012: Applied Finance with R
> www.RinFinance.com
> 
> 
> On Mon, Apr 30, 2012 at 12:38 PM, Gordon Erlebacher
> <gordon.erlebach at gmail.com> wrote:
> > Hi,
> >
> > I have a xts object. Given a date, how do I get the index into the
> > array? Is there a pre-written function?
> >
> > Thanks,
> >
> >  Gordon
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- 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.
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- 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.



-- 

http://censix.com



More information about the R-SIG-Finance mailing list