r - Increment a date by some time period -


when using "+" operator increment date (or date-time), how specify increment in days (or months, or weeks, or years)?

> sys.date() [1] "2013-08-23" > sys.date() + 1 [1] "2013-08-24" > isodate(2013,8,23) [1] "2013-08-23 12:00:00 gmt" > isodate(2013,8,23) + 1 [1] "2013-08-23 12:00:01 gmt" 

use lubridate::days

> require(lubridate) > sys.date() [1] "2013-08-23" > sys.date() + days(1) [1] "2013-08-24" > isodate(2013, 8, 23) [1] "2013-08-23 12:00:00 gmt" > isodate(2013, 8, 23) + days(1) [1] "2013-08-24 12:00:00 gmt" 

with lubridate, can use years(), seconds(), etc., or define own duration.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -