R-beta: quantile
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
27 Feb 1998 13:59:55 +0100
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._