scales::percent appears not to be documented.

Details:

At http://cran.r-project.org/web/packages/scales/scales.pdf, equivalently in 
?percent, I find no answer to the following two questions.

(1) How can I specify the number of decimal points in a call to percent()? For 
instance, 0.010101 could be

1%

1.0%

1.01%

etc. depending on what kind of report I'm writing.

I can control precision myself by writing

mypercent<-function(theargument, siglevel=2) {
        stopifnot(is.numeric(theargument))
        paste(signif(theargument, siglevel) * 100, "%", sep="")
}

and then we have

mypercent(0.010101)
[1] "1%"
mypercent(0.010101, 5)
[1] "1.0101%"
mypercent(0.010101, 3)
[1] "1.01%"

(2) What is the function precision() inside percent()? I find no documentation 
for it, and in fact it does not appear in the search path. Nor does round_any().

percent(0.010101)
[1] "1.01%"
percent
function (x) {
    x <- round_any(x, precision(x)/100)
    str_c(comma(x * 100), "%")
}
<environment: 0x10c0f9350>
find("precision")
character(0)
find("round_any")
character(0)


Thanks for any insights

Jacob Wegelin

sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
 [1] tools     grid      splines   stats     graphics  grDevices utils     
datasets  methods   base

other attached packages:
[1] scales_0.2.3    xtable_1.7-0    reshape2_1.2.2  moments_0.13    
corrplot_0.70   ggplot2_0.9.3.1 nlme_3.1-108

loaded via a namespace (and not attached):
 [1] colorspace_1.2-0   dichromat_1.2-4    digest_0.6.0       gtable_0.1.2      
 labeling_0.1       lattice_0.20-13    MASS_7.3-23        munsell_0.4
[9] plyr_1.8 proto_0.3-10 psych_1.2.8 RColorBrewer_1.0-5 stringr_0.6.2


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to