Skip to content
Back to formatted view

Raw Message

Message-ID: <87haoii8vw.fsf@gnu.org>
Date: 2012-11-22T04:01:07Z
From: Sam Steingold
Subject: printing difftime summary
In-Reply-To: <1353535476.4666.YahooMailNeo@web142604.mail.bf1.yahoo.com> (arun's message of "Wed, 21 Nov 2012 14:04:36 -0800 (PST)")

Hi,

> * arun <fznegcvax111 at lnubb.pbz> [2012-11-21 14:04:36 -0800]:
>
> Are you looking for some other function (difftime2string)
> ot just remove the quotes from the printed output?

I am wondering what others do when they want to see a summary of difftime.

> If it is the latter, then this should do it.
> res<-do.call(data.frame,lapply(s,difftime2string))
> ?names(res)<-names(s)
> ?res
> #?????? Min.?? 1st Qu.??? Median???? Mean? 3rd Qu.????? Max.
> #1 500.00 ms 17.12 min 99.48 min 8.30 hrs 8.05 hrs 6.98 days

cool, thanks.
I now think that what I want is
--8<---------------cut here---------------start------------->8---
difftime.summary <- function (v) {
  s <- summary(as.numeric(v))
  r <- as.data.frame(sapply(s,difftime2string),stringsAsFactors=FALSE)
  names(r) <- c("string")
  r[[units(v)]] <- s
  r
}
> difftime.summary(infl$delay)
           string     secs
Min.    500.00 ms      0.5
1st Qu. 17.12 min   1027.0
Median  99.48 min   5969.0
Mean     8.30 hrs  29870.0
3rd Qu.  8.05 hrs  28970.0
Max.    6.98 days 603100.0
--8<---------------cut here---------------end--------------->8---


-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://ffii.org http://jihadwatch.org http://memri.org
http://www.memritv.org http://camera.org http://mideasttruth.com
A computer scientist is someone who fixes things that aren't broken.