Subsetting zoo series by a time that is not in the series

Viewed 1409

Is there a good package in R that allows to sub-set (i.e. index into) timeseries by times that are not in the time series? E.g. for financial applications, indexing a price series by a time stamp that is not in the database, should return the latest available price before the time stamp.

in code, this is what I would like

n =15
full.dates = seq(Sys.Date(), by = 'day', length = n)
series.dates = full.dates[c(1:10, 12, 15)] 
require(zoo)
series=zoo(rep(1,length(series.dates)), series.dates)
series[full.dates[11]]

this returns

Data:
numeric(0)

Index:
character(0)

however, I would like this to return the value of the last existing date before full.dates[11], which is full.dates[10]:

series[full.dates[10]]
2014-01-03 
     1 

Thanks

3 Answers
Related