A) ?str
A common mistake by beginners is to fail to import to the appropriate data 
type. Learn to confirm your data types.
B) ?dput
Provide reproducible examples. dput is one useful tool for creating such.
C) Sys.setenv(TZ="CEST")
If you can't use ?chron or ?Date, then setting the default timezone before 
converting to POSIXct can save you headaches. (From your code, it seems likely 
that chron should be fine for your application.)
D) Read the posting guide.
Sometimes knowing which platform you are using can change the answer. The 
posting guide can help you clarify how you are using R.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

B Laura <gm.spam2...@gmail.com> wrote:

Hello all!

As beginner I'm struggling for a while with time zones issue and can't find
a suitable solution.
I would be grateful for any help.

Dataset imported from excel has a variable transplant.date which has been
recorded with CET time zone.

> subDataset$transplant.date
[1] "2000-01-01 CET" "2000-01-01 CET" "2000-01-02 CET" "2000-01-02 CET"
"2000-01-02 CET" "2000-01-02 CET" "2000-01-04 CET" "2000-01-04 CET"
"2000-01-04 CET" "2000-01-04 CET" "2000-01-04 CET" "2000-01-05 CET"
"2000-01-05 CET"
[14] "2000-01-05 CET" "2000-01-05 CET"


However
> Sys.time()
[1] "2011-07-06 15:22:44 CEST"

I need to calculate time difference in days but I'm still getting wrong
calculations. Most likely is this time zone issue.


> as.numeric(as.Date("2000-1-1")-as.Date(subDataset$transplant.date))
[1] 1 1 0 0 0 0 -2 -2 -2 -2 -2 -3 -3 -3 -3


Truncation doesn't help either

>
trunc(as.Date("2000-1-1"),"days")-trunc(as.Date(subDataset$transplant.date),"days")
Time differences in days
[1] 1 1 0 0 0 0 -2 -2 -2 -2 -2 -3 -3 -3 -3


Are there any useful tips to cope with this?

Thank you very much!
Laura

        [[alternative HTML version deleted]]

_____________________________________________

R-help@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.


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to