0

The following R code is not working properly:

seq(as.Date("2016/3/31"),as.Date("2016/6/30"),by = "month")

The output is:

"2016-03-31" "2016-05-01" "2016-05-31"

But the expected output is:

"2016-03-31" "2016-04-30" "2016-05-31""2016-06-30"

Spacedman
  • 92,590
  • 12
  • 140
  • 224

1 Answers1

0

I think this is a duplicate of Generate a sequence of the last day of the month over two years and they suggested to do the following

ymd("2010-02-01")+ months(0:23)-days(1)

Simply specify the first day of the next month and generate a sequence from that but subtract 1 days from it to get the last day of the preceding month.

Community
  • 1
  • 1
Bill Perry
  • 463
  • 1
  • 5
  • 13
  • Thanks for answer :). If i reduce last date it performing perfectly seq(as.Date("2016/3/30"),as.Date("2016/6/30"),by = "month". – Manikandan Wfm Apr 08 '16 at 19:53