From p.dalgaard@biostat.ku.dk  Fri Feb 27 12:59:55 1998
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 27 Feb 1998 13:59:55 +0100
Subject: R-beta: quantile
In-Reply-To: Martyn Plummer's message of Fri, 27 Feb 1998 13:44:51 +0100
References: <199802270827.JAA06769@sophie.ethz.ch> <34F6B543.68813EFB@iarc.fr>
Message-ID: <x2ra4p6w4z.fsf@blueberry.kubism.ku.dk>

Martyn Plummer <plummer@iarc.fr> writes:

> What about just using format(100*probs)?
> 
> R> foo <- function(probs) paste(format(100 * probs), "%", sep="")
> R> foo(c(0.02,0.25,0.50))
> [1] " 2%" "25%" "50%"
> R> foo(c(0.025,0.25,0.50))
> [1] " 2.5%" "25.0%" "50.0%"
> R> foo(c(0.0125,0.25,0.50))
> [1] " 1.25%" "25.00%" "50.00%"
> 
> I am probably missing something but this seems to be "smart" enough.


I can do one better, I think:

> sapply(c(0.1,2.5,25),format)
[1] "0.1" "2.5" "25" 
> foo <- function(probs) paste(sapply(100 * probs,format), "%", sep="")
> foo(c(0.02,0.25,0.50))
[1] "2%"  "25%" "50%"
> foo(c(0.025,0.25,0.50))
[1] "2.5%" "25%"  "50%" 
> foo(c(0.0125,0.25,0.50))
[1] "1.25%" "25%"   "50%"  


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


R-beta: quantile
Peter Dalgaard BSA