Function %m+%
from lubridate adds one month without exceeding last day of the new month.
library(lubridate)
(d <- ymd("2012-01-31"))
1 parsed with %Y-%m-%d
[1] "2012-01-31 UTC"
d %m+% months(1)
[1] "2012-02-29 UTC"
More Related Contents:
- How to subtract years?
- How to prevent ifelse() from turning Date objects into numeric objects
- Looping over a Date or POSIXct object results in a numeric iterator
- Changing date format in R
- Split date-time column into Date and time variables
- Extract month and year from a zoo::yearmon object
- Generate a sequence of the last day of the month over two years
- Is there a more elegant way to convert two-digit years to four-digit years with lubridate?
- R: How to handle times without dates?
- Extract Month and Year From Date in R
- Split date into different columns for year, month and day
- Converting Date formats in R [closed]
- Format for ordinal dates (day of month with suffixes -st, -nd, -rd, -th)
- How to sort a data frame by date
- convert character to date *quickly* in R [duplicate]
- Converting date in Year.decimal form in R
- Change day of the month in a Date to first day (01)
- Sort year-month column by year AND month
- R ifelse avoiding change in date format [duplicate]
- Creating a unique sequence of dates
- How to account for leap years?
- Checking if Date is Between two Dates in R
- Order x axis day values in ggplot2
- R: How to get the Week number of the month
- Subset data.frame by date
- set date range in ggplot
- change a column from birth date to age in r
- Convert two-digit years to four-digit years with correct century
- Create a Vector of All Days Between Two Dates
- Using geom_rect for time series shading in R