【发布时间】:2019-02-27 05:39:51
【问题描述】:
我想在步骤 1 个月内创建两个指定时刻之间的日期向量,如本线程 (Create a Vector of All Days Between Two Dates) 中所述,然后将其转换为数据可视化因子。
但是,我希望在 YYYY-Mon 中有日期,即。 2010 年 2 月,格式。但到目前为止,我只设法使用标准格式 2010-02-01 的日期,使用如下代码:
require(lubridate)
first <- ymd_hms("2010-02-07 15:00:00 UTC")
start <- ymd(floor_date(first, unit="month"))
last <- ymd_hms("2017-10-29 20:00:00 UTC")
end <- ymd(ceiling_date(last, unit="month"))
> start
[1] "2010-02-01"
> end
[1] "2017-11-01"
如何将格式更改为 YYYY-Mon?
【问题讨论】: