[R] suppressing time shift in plot of POSIXct object?

jim holtman jholtman at gmail.com
Tue Jan 27 01:33:22 CET 2009


Try:

Sys.setenv(TZ="EST")
plot(y ~ t, type = "l")

You can save TZ before you set it and then restore it.

On Mon, Jan 26, 2009 at 5:47 PM, Jim Porzak <jporzak at gmail.com> wrote:
> Friends,
>
> I have a POSIXct vector "located" in EST timezone. When I plot against
> it here in PST, the time axis is shifted 3 hours back in time. IOW,
> plot adjusts for time zone difference. Now that's really great, if
> that's what one wants. However, I want time axis to use actual times
> in object (without any shift).
>
> For example:
>
> n <- 360
> y <- rnorm(n)
> t <- seq(from = as.POSIXct("2009-01-26 12:00:00", tz = "EST"), by =
> 60, length.out = n)
> head(t)
> #[ 1] "2009-01-26 12:00:00 EST" "2009-01-26 12:01:00 EST" "2009-01-26
> 12:02:00 EST"
> # [4] "2009-01-26 12:03:00 EST" "2009-01-26 12:04:00 EST" "2009-01-26
> 12:05:00 EST"
> Sys.timezone()
> # [1] "PST"
>
> #But doing:
> plot(y ~ t, type = "l")
>
> results in plot starting at 09:00 (here in California)
>
> I've poked around in help, etc but haven't any way to force use of
> timezone in t.
>
> What am I missing?
>
> TIA,
> Jim Porzak
> TGN.com
> San Francisco, CA
> http://www.linkedin.com/in/jimporzak
> use R! Group SF: http://ia.meetup.com/67/
>
> ______________________________________________
> 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
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list