[R] Help with creating date as POSIXct

jim holtman jholtman at gmail.com
Thu Sep 1 16:01:02 CEST 2011


try this:

> myDate <- as.POSIXct(day, format = "%y%m%d")
> myDate
[1] "2011-08-09 EDT"
> myDate <- myDate + 0:3600
> str(myDate)
 POSIXct[1:3601], format: "2011-08-09 00:00:00" "2011-08-09 00:00:01"
"2011-08-09 00:00:02" ...
>

On Thu, Sep 1, 2011 at 7:18 AM, J. Augusiak <jaugusiak at googlemail.com> wrote:
> Dear list,
>
>
>
> I want to create a POSIX time vector as follows:
>
>
>
> day    <- as.character("110809")
>
> time.t <- 1:3600
>
> t.min  <- time.t %/% 60
>
> t.sec  <- time.t-t.min*60
>
> DATE   <- as.POSIXct(strptime(paste(day,t.min,t.sec),"%y%m%d %M%S"))
>
> Tail(DATE)
>
>
>
>
>
> The problem is that the last element (3600) returns a NA and I don't
> understand why. 600, 1200, 2400 no problem, only 3600. Any helpful advice is
> highly appreciated :)
>
>
>
> Cheers,
>
>
>
> Jacqueline
>
>
>
>
>
>
>        [[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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list