Automatically create date sequences with different starting dates in R -



Automatically create date sequences with different starting dates in R -

i can create desired date sequences using next code:

datetwoweeks1 <- seq(as.date("2010/8/6"), as.date("2011/8/5"), = "2 weeks") datetwoweeks2 <- seq(as.date("2010/8/7"), as.date("2011/8/5"), = "2 weeks") datetwoweeks3 <- seq(as.date("2010/8/8"), as.date("2011/8/5"), = "2 weeks")

however, automate creation of date sequences 14 different starting dates. have 1 time series starting on 6th of august 2010, next time series starting on 7th, on until 19th of august 2010.

how can automate this? tried using "paste" function couldn't next code work:

for (i in 6:19){ timetwoweeks[i] <- seq(as.date(paste("2010/8/", i)), as.date("2011/8/5"), = "2 weeks") }

any direct help or linkage other websites/posts appreciated.

here go:

timetwoweeks <- lapply(as.date("2010/8/6") + 0:13, function(x) seq(x, as.date("2011/8/5"), = "2 weeks"))

r date

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -