[R] problems in vectors of dates_times

Troels Ring tring at gvdnet.dk
Fri Apr 7 09:48:20 CEST 2017


Thanks a lot - good idea:

I put

Sys.setenv(TZ = "UTC")

ahead of the code - solves the problem!

Thanks a lot


Den 07-04-2017 kl. 09:26 skrev Mark Leeds:
> Hi Troels: This is off-list so as to not clog the list with my noise 
> because my suggestion may not work. I really don't know that much
> about time-zones. but.   I ran your code and it "worked" but all the 
> times were correctly time stamped but they changed from UTC to GMT.
> in time-zone. In your
> case, they changed to something and the time got shifted it looks 
> like. So, definitely it has to do with how your time-zones are set. In 
> my .Rprofile, I have something.
> Let me check. ... time passes .....  I have below in my .Rprofile. So 
> my guess is that, if you want things to remain UTC, then put below
> in your .Rprofile but change it from "GMT" to "UTC". Others may have 
> different solutions but that might work. If you don't have that, then 
> R decides what to use and I'm not sure how it decides.
>
> Sys.setenv(TZ = "GMT")
>
> #print("LOADING MASS LIBRARY")
> #ibrary("MASS")
> #print("LOADING LATTICE LIBRARY")
> #library("lattice")
>
>
>
>
> :~>
>
> On Fri, Apr 7, 2017 at 3:00 AM, Troels Ring <tring at gvdnet.dk 
> <mailto:tring at gvdnet.dk>> wrote:
>
>     Thanks a lot - perhaps it is just understanding how times dates
>     are handled, sorry to bother if that is just the case
>
>     C[1]==A[1]  # TRUE
>
>     but
>
>     C[1]
>     [1] "2013-03-28 07:00:00 CET"
>     A[1]
>     [1] "2013-03-28 06:00:00 UTC"
>
>
>
>
>
>
>     Den 07-04-2017 kl. 08:27 skrev Ulrik Stervbo:
>
>         Hi Troels,
>
>         I get no error. I think we need more information to be of any
>         help.
>
>         Best wishes,
>         Ulrik
>
>         On Fri, 7 Apr 2017 at 08:17 Troels Ring <tring at gvdnet.dk
>         <mailto:tring at gvdnet.dk>> wrote:
>
>             Dear friends - I have further problems  handling
>             dates_times, as
>             demonstrated below where concatenating two formatted
>             vectors of
>             date_times results in errors.
>             I wonder why this happens and what was wrong in trying to
>             take these two
>             vectors together
>             All best wishes
>             Troels Ring
>             Aalborg, Denmark
>             Windows
>             R version 3.3.2 (2016-10-31)
>
>
>             A <- structure(c(1364450400, 1364450400, 1364536800,
>             1364623200,
>             1364709600,
>             1364796000, 1364882400, 1364968800, 1365055200,
>             1365141600, 1365228000,
>             1365314400, 1365400800), class = c("POSIXct", "POSIXt"),
>             tzone = "UTC")
>             A
>             B <- structure(c(1365141600, 1365228000, 1365314400,
>             1365400800,
>             1365487200,
>             1365573600, 1365660000, 1365746400, 1365832800,
>             1365919200, 1366005600,
>             1366092000), class = c("POSIXct", "POSIXt"), tzone = "UTC")
>             B
>             C <- c(A,B)
>             C
>
>             ______________________________________________
>             R-help at r-project.org <mailto:R-help at r-project.org> mailing
>             list -- To UNSUBSCRIBE and more, see
>             https://stat.ethz.ch/mailman/listinfo/r-help
>             <https://stat.ethz.ch/mailman/listinfo/r-help>
>             PLEASE do read the posting guide
>             http://www.R-project.org/posting-guide.html
>             <http://www.R-project.org/posting-guide.html>
>             and provide commented, minimal, self-contained,
>             reproducible code.
>
>                 [[alternative HTML version deleted]]
>
>         ______________________________________________
>         R-help at r-project.org <mailto:R-help at r-project.org> mailing
>         list -- To UNSUBSCRIBE and more, see
>         https://stat.ethz.ch/mailman/listinfo/r-help
>         <https://stat.ethz.ch/mailman/listinfo/r-help>
>         PLEASE do read the posting guide
>         http://www.R-project.org/posting-guide.html
>         <http://www.R-project.org/posting-guide.html>
>         and provide commented, minimal, self-contained, reproducible code.
>
>
>     ______________________________________________
>     R-help at r-project.org <mailto:R-help at r-project.org> mailing list --
>     To UNSUBSCRIBE and more, see
>     https://stat.ethz.ch/mailman/listinfo/r-help
>     <https://stat.ethz.ch/mailman/listinfo/r-help>
>     PLEASE do read the posting guide
>     http://www.R-project.org/posting-guide.html
>     <http://www.R-project.org/posting-guide.html>
>     and provide commented, minimal, self-contained, reproducible code.
>
>


	[[alternative HTML version deleted]]



More information about the R-help mailing list