[R] Create Time Lists with a for loop
Rui Barradas
ruipbarradas at sapo.pt
Mon Oct 28 21:47:55 CET 2013
Hello,
Instead of string manipulation you should think of POSIXt objects. And
maybe ?seq.POSIXt will help.
first <- strptime("2011-10-12 10:59:00","%Y-%m-%d %H:%M:%S")
last <- strptime("2011-10-12 11:13:00","%Y-%m-%d %H:%M:%S")
seq(first, last, by = "5 min")
Hope this helps,
Rui Barradas
Em 28-10-2013 18:42, Alaios escreveu:
> Dear all,
> in my code I have written the following list
>
> TimeFramesShort <-list(c(strptime("2011-10-12 10:59:00","%Y-%m-%d %H:%M:%S"),strptime("2011-10-13 11:02:00","%Y-%m-%d %H:%M:%S")) # rest items were truncated
>
>
> I was wondering if could somehow take the first element of the list and create element that are only 5 minutes apart something like
> list(c(strptime("2011-10-12 10:59:00","%Y-%m-%d %H:%M:%S"),strptime("2011-10-12 11:04:00","%Y-%m-%d %H:%M:%S"),
> c(strptime("2011-10-12 11:04:00","%Y-%m-%d %H:%M:%S"),strptime("2011-10-12 11:09:00","%Y-%m-%d %H:%M:%S"),
> c(strptime("2011-10-12 11:09:00","%Y-%m-%d %H:%M:%S"),strptime("2011-10-12 11:13:00","%Y-%m-%d %H:%M:%S")
> ...
> and so on.
>
> The problem I see is that pure string manipulation will not work as after one hour that should also make changes in the hours.
>
> Regards
> Alex
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list