[R] timeAlign

Gabor Grothendieck ggrothendieck at gmail.com
Tue Apr 11 02:37:07 CEST 2006


Try this.

dd <- Sys.time()  # test data

lt <- as.POSIXlt(dd)

ISOdate(1900+lt$year, 1, 1, 0, tz = "")
ISOdate(1901+lt$year, 1, 1, 0, tz = "")

seq(now, length = 2, by = paste("-", lt$wday, " day", sep =""))[2]
seq(now, length = 2, by = paste(7-lt$wday, "day"))[2]

with(lt, ISOdate(1901+year, mon, mday, 0, tz = ""))
with(lt, ISOdate(1901+year, mon, mday, 23, 59, 59, tz = ""))+1



On 4/10/06, Omar Lakkis <uofiowa at gmail.com> wrote:
> I use POSIXct for datetimes. Is thee a timeAlign function that I can
> use where :
>
> align by year
>      direction -1 ==> start of this year
>      direction 1  ==> start of next year
> align by week
>      direction -1 ==> date on last sunday
>      direction 1  ==> date on next sunday
> align by day
>      direction -1 ==> time at past midnight
>      direction 1  ==> time at this comming midnight
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list