[R] Averaging dates?
Hi, What's the best way to average dates? I though mean.POISXct would work fine but... a [1] 2007-04-02 19:22:00 WEST b [1] 2007-03-17 16:23:00 WET class(a) [1] POSIXt POSIXct class(b) [1] POSIXt POSIXct mean(a,b) [1] 2007-04-02 19:22:00 WEST mean(b,a) [1] 2007-03-17 16:23:00 WET ?! Thanks in advance for any advice, -- Sérgio Nunes __ R-help@stat.math.ethz.ch 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.
Re: [R] Averaging dates?
On Wed, 20 Jun 2007, Sérgio Nunes wrote: Hi, What's the best way to average dates? I though mean.POISXct would work fine but... a [1] 2007-04-02 19:22:00 WEST b [1] 2007-03-17 16:23:00 WET class(a) [1] POSIXt POSIXct class(b) [1] POSIXt POSIXct mean(a,b) [1] 2007-04-02 19:22:00 WEST mean(b,a) [1] 2007-03-17 16:23:00 WET Would you usually call mean() in this way? mean(1, 2) mean(2, 1) Probably not... mean() expects a vector, try mean(c(a, b))! Z ?! Thanks in advance for any advice, -- Sérgio Nunes __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] Averaging dates?
You need to call 'mean.POSIXct' with a single vector: a [1] 2007-01-01 12:00:00 GMT b [1] 2007-07-01 14:22:00 GMT mean(c(a,b)) [1] 2007-04-02 01:11:00 GMT On 6/20/07, Sérgio Nunes [EMAIL PROTECTED] wrote: Hi, What's the best way to average dates? I though mean.POISXct would work fine but... a [1] 2007-04-02 19:22:00 WEST b [1] 2007-03-17 16:23:00 WET class(a) [1] POSIXt POSIXct class(b) [1] POSIXt POSIXct mean(a,b) [1] 2007-04-02 19:22:00 WEST mean(b,a) [1] 2007-03-17 16:23:00 WET ?! Thanks in advance for any advice, -- Sérgio Nunes __ R-help@stat.math.ethz.ch 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 you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.