[R] "options" in R

William Dunlap wdunlap at tibco.com
Wed Oct 3 22:42:51 CEST 2012


In S+ 8.2 help(options) says

   time.zone
   a character string specifying the default time zone when none is given in a time object.

Its default value is "GMT".  It is used as the default value of the 'zone' argument to the
constructors of "timeDate" objects (where it says "time object" it could say "timeDate
object", if it wanted to be pedantic).

E.g., with the default "GMT" (and the US-default versions of the other timeDate-related
options) we get
> timeSeq("Nov 2, 2012 07:00pm", by="hours", k.by=12, len=10)
 [1] 11/02/2012 19:00:00.000 11/03/2012 07:00:00.000 11/03/2012 19:00:00.000 11/04/2012 07:00:00.000
 [5] 11/04/2012 19:00:00.000 11/05/2012 07:00:00.000 11/05/2012 19:00:00.000 11/06/2012 07:00:00.000
 [9] 11/06/2012 19:00:00.000 11/07/2012 07:00:00.000
> .Last.value at time.zone
[1] "GMT"
> timeSeq("Nov 2, 2012 07:00pm", by="hours", k.by=12, len=10, zone="Pacific")
 [1] 11/02/2012 19:00:00.000 11/03/2012 07:00:00.000 11/03/2012 19:00:00.000 11/04/2012 06:00:00.000
 [5] 11/04/2012 18:00:00.000 11/05/2012 06:00:00.000 11/05/2012 18:00:00.000 11/06/2012 06:00:00.000
 [9] 11/06/2012 18:00:00.000 11/07/2012 06:00:00.000
> .Last.value at time.zone
[1] "Pacific"
> options(time.zone="Arizona")
> timeSeq("Nov 2, 2012 07:00pm", by="hours", k.by=12, len=10)
 [1] 11/02/2012 19:00:00.000 11/03/2012 07:00:00.000 11/03/2012 19:00:00.000 11/04/2012 07:00:00.000
 [5] 11/04/2012 19:00:00.000 11/05/2012 07:00:00.000 11/05/2012 19:00:00.000 11/06/2012 07:00:00.000
 [9] 11/06/2012 19:00:00.000 11/07/2012 07:00:00.000
> .Last.value at time.zone
[1] "Arizona"

(US/Pacific switches to 'standard' ('winter') time in that time period, but GMT and Arizona do not switch.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of David Winsemius
> Sent: Wednesday, October 03, 2012 1:05 PM
> To: Santosh
> Cc: r-help
> Subject: Re: [R] "options" in R
> 
> 
> On Oct 3, 2012, at 11:00 AM, Santosh wrote:
> 
> > Dear Rxperts,
> > Was wondering if there is any function in R similar to
> > options("time.zone"): found in S-Plus that can help in looking at the
> > default timezone settings..
> 
> Many of us have no way to understand questions based on analogies with S. Are you
> asking how to see the current TZ?
> 
> > attr(as.POSIXlt(Sys.time()), "tzone"  )
> [1] ""    "PST" "PDT"
> 
> 
> Your timezone is handled by your OS (and the printed output is handled by print.POSIXct,
> which has options for converting to other TZs).  From the timezones  help page:
> 
> "Note that except on Windows, the operation of time zones is an OS service, and even
> on Windows a third-party database is used and can be updated (see the section on 'Time
> zone names')."
> 
> Or are you asking where to find the range of possible values?
> 
> This is the first example in the help page for
> 
>  ?timezones
> 
> zfile <- "/usr/share/zoneinfo/zone.tab"
> tzones <- read.delim(tzfile, row.names = NULL, header = FALSE,
>     col.names = c("country", "coords", "name", "comments"),
>     as.is = TRUE, fill = TRUE, comment.char = "#")
> str(tzones$name)
>  chr [1:410] "Europe/Andorra" "Asia/Dubai" "Asia/Kabul" "America/Antigua"
> "America/Anguilla" ...
> 
> --
> David Winsemius, MD
> Alameda, CA, USA
> 
> ______________________________________________
> 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