4

我想使用 R 将日期范围打印为字符串。以下是我所做的

> startDate <- as.Date("2005-02-02")
> endDate <- as.Date("2005-02-07")
> dates <- startDate:endDate
> dates
[1] 12816 12817 12818 12819 12820 12821

这里不是像我们打印 startDate 时那样将日期显示为字符串

> startDate
[1] "2005-02-02"

它显示了时代。

我真正想要的是日期的字符串表示,而不是纪元日。我什至尝试了以下没有任何运气

> as.character(dates)
[1] "12816" "12817" "12818" "12819" "12820" "12821"

如何打印日期字符串而不是纪元日?

4

1 回答 1

6
dates <- seq(startDate,endDate,by="day")
print(dates)

你可能想看看?seq.Date

于 2013-01-04T13:22:57.267 回答