Hello all, Could someone help me with the time zones in understandable & practical way? I got completely stucked with this.
Have googled for a while and read the manuals, but without solutions... ------------------------------------------------------------------- When data imported from Excel 2007 into R (2.13) all time variables, depending on date (summer or winter) get (un-asked for it!) a time zone addition CEST (for summer dates) or CET (for winter dates). > Dataset Start End1 End2 days2End1.from.Excel days2End2.from.Excel days2End1.in.R days2End2.in.R 1 2010-01-01 2011-01-01 2012-01-01 365 730 365 days 730.0000 days 2 2010-02-01 2011-02-01 2012-01-01 365 699 365 days 699.0000 days 3 2010-03-01 2011-03-01 2012-01-01 365 671 365 days 671.0000 days 4 2010-04-01 2011-04-01 2012-01-01 365 640 365 days 640.0417 days 5 2010-05-01 2011-05-01 2012-01-01 365 610 365 days 610.0417 days 6 2010-06-01 2011-06-01 2012-01-01 365 579 365 days 579.0417 days 7 2010-07-01 2011-07-01 2012-01-01 365 549 365 days 549.0417 days 8 2010-08-01 2011-08-01 2012-01-01 365 518 365 days 518.0417 days 9 2010-09-01 2011-09-01 2012-01-01 365 487 365 days 487.0417 days 10 2010-10-01 2011-10-01 2012-01-01 365 457 365 days 457.0417 days 11 2010-11-01 2011-11-01 2012-01-01 365 426 365 days 426.0000 days 12 2010-12-01 2011-12-01 2012-01-01 365 396 365 days 396.0000 days > Dataset$Start [1] "2010-01-01 CET" "2010-02-01 CET" "2010-03-01 CET" "2010-04-01 CEST" "2010-05-01 CEST" "2010-06-01 CEST" "2010-07-01 CEST" "2010-08-01 CEST" "2010-09-01 CEST" "2010-10-01 CEST" "2010-11-01 CET" "2010-12-01 CET" > Dataset$End1 [1] "2011-01-01 CET" "2011-02-01 CET" "2011-03-01 CET" "2011-04-01 CEST" "2011-05-01 CEST" "2011-06-01 CEST" "2011-07-01 CEST" "2011-08-01 CEST" "2011-09-01 CEST" "2011-10-01 CEST" "2011-11-01 CET" "2011-12-01 CET" > Dataset$End2 [1] "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" "2012-01-01 CET" Variables 'days2End1.from.Excel and 'days2End2.from.Excel' are calculated in Excel. Same calculation (with same outcome!) I would like to be able to perform with R. Variables 'days2End1.in.R' and 'days2End2.in.R are calculated with R. > Dataset$days2End1.from.Excel [1] 365 365 365 365 365 365 365 365 365 365 365 365 > Dataset$days2End1.in.R <- with(Dataset, End1- Start) > Dataset$days2End1.in.R Time differences in days [1] 365 365 365 365 365 365 365 365 365 365 365 365 attr(,"tzone") [1] "" > Dataset$days2End2.from.Excel [1] 730 699 671 640 610 579 549 518 487 457 426 396 > Dataset$days2End2.in.R <- with(Dataset, End2- Start) > Dataset$days2End2.in.R Time differences in days [1] 730.0000 699.0000 671.0000 640.0417 610.0417 579.0417 549.0417 518.0417 487.0417 457.0417 426.0000 396.0000 attr(,"tzone") [1] "" Quastion 1: As you can see 'Dataset$days2End2.in.R' gives wrong 'day' calculation at time period April until October, when CEST (summer) times are recorded 640.0417 610.0417 579.0417 549.0417 518.0417 487.0417 457.0417 giving decimals on days, where round days expected (640 610 579 549 518 487 457). Can someone explain me how to deal with it in R? What is the best way to calculate days in R getting correct calculations? Question 2: As I only need to work with dates without time and without time zones, I would be happy to remove them if possible. I tried already the trunc() function but without succes. The result doesn't change. > Dataset$days2End2.in.R.TRUNC <- with(Dataset, trunc(End2)- trunc(Start)) > Dataset$days2End2.in.R.TRUNC Time differences in days [1] 730.0000 699.0000 671.0000 640.0417 610.0417 579.0417 549.0417 518.0417 487.0417 457.0417 426.0000 396.0000 attr(,"tzone") [1] "" I would be happy if someone could light up this thing. Many thanks in advance! 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.