[Rd] Wishlist: abs method for difftime
Stephen D. Weigand
weigand.stephen at charter.net
Fri Dec 8 05:29:33 CET 2006
I am often taking the absolute value of a difftime object (after
coercing it to numeric) in order to see how far apart in time
two events are. For example, I might want to know if two events
occurred within 100 days of each other using something like
abs(difftime(Date1, Date2)) < 100
Below is a suggestion for an abs.difftime:
abs.difftime <- function(x)
{
structure(abs(as.numeric(x)),
class = class(x),
units = attr(x, "units"))
}
I think these changes to difftime.Rd would document this:
1) Add \alias{abs.difftime}
2) In the first paragraph of \details change
"There is a \code{\link{round}} method for objects of this class,
as well as..."
to
"There are \code{\link{round}} and \code{\link{abs}} methods for
objects of this class, as well as..."
Thanks for considering this,
Stephen
Rochester, Minnesota, USA
More information about the R-devel
mailing list