From weigand.stephen at charter.net  Fri Dec  8 05:29:33 2006
From: weigand.stephen at charter.net (Stephen D. Weigand)
Date: Thu, 7 Dec 2006 22:29:33 -0600
Subject: [Rd] Wishlist: abs method for difftime
Message-ID: <82f0767b3e86190f628bc5facfcee096@charter.net>

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



[Rd] Wishlist: abs method for difftime
Stephen D. Weigand