Re: [R] Lag vector of dates by vector of days

2012-02-01 Thread Jorge I Velez
Not the best way but it seems to work: do.call(c, lapply(1:length(n), function(i) input[i] + n[i])) Also, the lubridate < http://cran.r-project.org/web/packages/lubridate/index.html> package might be useful. HTH, Jorge.- On Wed, Feb 1, 2012 at 11:45 AM, RNoob <> wrote: > Dear All, > > I am lo

Re: [R] Lag vector of dates by vector of days

2012-02-01 Thread R. Michael Weylandt
input + n Michael On Wed, Feb 1, 2012 at 11:45 AM, RNoob wrote: > Dear All, > > I am looking for a function to get lagged dates from an input vector of > dates, whereas the lag is specified by another vector. Each date is lagged > by a different number of days. (specified in vector n) > > Exampl

[R] Lag vector of dates by vector of days

2012-02-01 Thread RNoob
Dear All, I am looking for a function to get lagged dates from an input vector of dates, whereas the lag is specified by another vector. Each date is lagged by a different number of days. (specified in vector n) Example: input <- as.Date( c( "2002-01-30", "2002-02-24", "2002-03-31") ) n