I have two dates in R, and I want to create a vector of the dates in between them spaced at one-month intervals. However, R seems to be using 31-day intervals instead (sometimes?). For example:
x <- as.Date("31-01-1900", "%d-%m-%Y")
y <- as.Date("31-01-1901", "%d-%m-%Y")
seq(x, y, by="month")
[1] "1900-01-31" "1900-03-03" "1900-03-31" "1900-05-01" "1900-05-31"
[6] "1900-07-01" "1900-07-31" "1900-08-31" "1900-10-01" "1900-10-31"
[11] "1900-12-01" "1900-12-31" "1901-01-31"
What I wanted was a vector of dates, each of which is the final day in each month, like this:
[1] "1900-01-31" "1900-02-29" "1900-03-31" "1900-04-30" "1900-05-31"
[6] "1900-06-30" "1900-07-31" "1900-08-31" "1900-09-30" "1900-10-31"
[11] "1900-11-30" "1900-12-31" "1901-01-31"
Does R know the lengths of the months, or do I have to do it by hand?