...">

How to print a date range as a string?

I want to print a date range as a string using R. Here's what I did

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

Here instead of showing the date as a string, as it did when printing startDate

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

It shows an era.

What I really wanted was a string representation of dates, not days of an era. I even tried the following with no luck

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

How to print a date string, not days of an era?

+4
source share
1 answer
 dates <- seq(startDate,endDate,by="day") print(dates) 

Can you see ?seq.Date .

+6
source

All Articles