[R] weird to me interaction between time() and %%, %/%

Gabor Grothendieck ggrothendieck at gmail.com
Wed Sep 1 05:11:30 CEST 2010


On Tue, Aug 31, 2010 at 7:04 PM, Alistair Gray <aggray at paradise.net.nz> wrote:
> Dear List,
> I'm getting weird and unexpected behaviour using time and %%, or %/%. It's
> likely I'm not appreciating the nuances of floating point arithmetic. Or it
> could be a bug.
>

Here are two workarounds to get the year

   time(junk) - (cycle(junk) - 1) / frequency(junk)

   library(chron)
   month.day.year(junk)$year

and this will get the month as a number between 1 and 12:

   cycle(junk)


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list