R语言产生月末日期

seq(as.Date("2020-02-01"), length=12, by="1 month") - 1
[1] "2020-01-31" "2020-02-29" "2020-03-31" "2020-04-30" "2020-05-31" "2020-06-30" "2020-07-31" "2020-08-31" "2020-09-30" "2020-10-31" "2020-11-30" "2020-12-31"

ymd("2020-02-01")+ months(0:12)-days(1)
[1] "2020-01-31" "2020-02-29" "2020-03-31" "2020-04-30" "2020-05-31" "2020-06-30" "2020-07-31" "2020-08-31" "2020-09-30" "2020-10-31" "2020-11-30" "2020-12-31" "2021-01-31"

https://stackoverflow.com/questions/8333838/generate-a-sequence-of-the-last-day-of-the-month-over-two-years

posted @ 2021-07-07 19:32  船长博客  阅读(120)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!