R next_month()

Jmnote (토론 | 기여)님의 2019년 11월 28일 (목) 23:32 판

1 개요

R next_month()
require(lubridate)
mon = "2019-07"
t = as.Date(paste0(mon,'-01'))
month(t) = month(t) + 1
next_mon = format(t, "%Y-%m")
next_mon
## [1] "2019-08"
require(lubridate)
next_mon <- function(mon) {
  t = as.Date(paste0(mon,'-01'))
  month(t) = month(t) + 1
  format(t, "%Y-%m")
}
next_mon("2019-07")
## [1] "2019-08"
next_mon("2019-12")
## [1] "2020-01"

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}