Hello, I have the starting date in UNIX_TIME LONG number (number of milliseconds since 1970 jan 1st). Is there a way to generete the sequence of dates with monthly interval in POSIXct format like 2000-01-01 2000-02-01 2000-03-01 etc Thanks [[alternative HTML version deleted]]
Hello, Try the following. Y <- 2000:2001 M <- 1:12 D <- 1 x <- expand.grid(Y, M, D) Dates <- sort(as.Date(apply(x, 1, paste, collapse = "-"))) Hope this helps, Rui Barradas Em 30-11-2012 12:26, Vasilchenko Aleksander escreveu:> Hello, > > I have the starting date in UNIX_TIME LONG number (number of milliseconds > since 1970 jan 1st). > > Is there a way to generete the sequence of dates with monthly interval in > POSIXct format like > > 2000-01-01 > 2000-02-01 > 2000-03-01 > > etc > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
?seq.Date> seq(as.Date("2000-01-01"), len=5, by="1 mon")[1] "2000-01-01" "2000-02-01" "2000-03-01" "2000-04-01" "2000-05-01"> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Vasilchenko Aleksander > Sent: Friday, November 30, 2012 6:27 AM > To: r-help at r-project.org > Subject: [R] Generating sequences of dates > > Hello, > > I have the starting date in UNIX_TIME LONG number (number of > milliseconds > since 1970 jan 1st). > > Is there a way to generete the sequence of dates with monthly interval > in > POSIXct format like > > 2000-01-01 > 2000-02-01 > 2000-03-01 > > etc > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.