Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable R warning: timezone of object (UTC) is different than current timezone ()

I keep getting this warning: timezone of object (UTC) is different than current timezone (). My current timezone is "EET", as shown by Sys.timezone().

Is there a way to change the R timezone to UTC, instead of it taking the one from my system? Or to disable the warning?

like image 412
Meh Avatar asked Jan 06 '11 19:01

Meh


4 Answers

Try this:

Sys.setenv(TZ = "UTC")
like image 60
G. Grothendieck Avatar answered Nov 18 '22 19:11

G. Grothendieck


If there is provision for getting a local timezone it is from:

 Sys.timezone()
[1] ""  # So in my case nothing there

And there is no Sys.timezone()<- function

 Sys.time()
[1] "2011-01-06 16:01:10 EST"

But obviously something is to be had. And here is how to convert to another time zone:

 strftime(Sys.time() , tz="UTC")
[1] "2011-01-06 21:02:48"

For further specific advice perhaps if you offered the results of dput() on the object, we would all have access to any necessary attributes to answer further questions.

like image 33
IRTFM Avatar answered Nov 18 '22 19:11

IRTFM


If you are sure that your code works and other sources of warnings are not likely, then just put the call inside suppressWarnings().

For example,

require(quantmod)
getSymbols("FDX")
suppressWarnings(chartSeries(FDX,theme="white"))
like image 1
Patrick Avatar answered Nov 18 '22 17:11

Patrick


If you work with xts data type (let's call the xts object xts.ts) from the package xts you can use:

tzone(xts.ts) <- "America/Phoenix"

like image 1
Ghazal Avatar answered Nov 18 '22 19:11

Ghazal