It disappointed me. Even with lubridate I cannot get dates to support their type when I go through them. For instance:
require(lubridate) yearrange = ymd(20110101) + years(seq(4)) yearrange #[1] "2012-01-01 UTC" "2013-01-01 UTC" "2014-01-01 UTC" "2015-01-01 UTC" class(yearrange) #[1] "POSIXct" "POSIXt"
However, if I try to go through the years (creating a separate schedule for each year in my data set): I lose the formatting of the year and will have to redisplay the data
for (yr in yearrange) { show(yr) }
If I loop through with indexes, I return date objects:
for (i in seq(length(yearrange))) { show(yearrange[i]) } #[1] "2012-01-01 UTC" #[1] "2013-01-01 UTC" #[1] "2014-01-01 UTC" #[1] "2015-01-01 UTC"
Is there an easy way to avoid indexing without using foreach , or is this the only way?
beroe source share