[R] Rep command

Thomas Lumley tlumley at u.washington.edu
Sat Apr 26 00:19:32 CEST 2003


On Fri, 25 Apr 2003, Roger Peng wrote:

> That's not a bug, but the internal representation of the date as the
> number of seconds since the beginning of 1970.  See ?DateTimeClasses.  I
> guess rep coerces the argument to be numeric.
>

It's at least an infelicity (in Bill Venables' wonderful phrase) as there
is no way to recover the date without using the internal representation.
There isn't a simple fix, since rep() is not generic and it isn't
possible just to copy attributes over from the argument.

One general solution is to use rep() on a sequence of indexes into your
vector:

eg with a<-.leap.seconds

ind<-seq(length(a))
a[rep(ind,3)]
a[rep(ind,each=3)]
etc

and a special solution for converting numbers back into dates is to add
ISOdate(1970,1,1,hour=0).  It might be useful to have this as a variable,
something like

 .Epoch <- ISOdate(1970,1,1,hour=0)


	-thomas



More information about the R-help mailing list