out.of: Easily display fraction and percentages

Description Usage Arguments Value Examples

View source: R/NCmisc.R

Description

For a subset 'n' and total 'N', nicely prints text n/N and/or percentage Often we want to display proportions and this simple function reduces the required amount of code for fraction and percentage reporting. If insufficient digits are provided small percentage may truncate to zero.

Usage

1
out.of(n, N = 100, digits = 2, pc = TRUE, oo = TRUE, use.sci = FALSE)

Arguments

n

numeric, the count for the subset of N (the numerator)

N

numeric, the total size of the full set (the denominator)

digits,

integer, the number of digits to display in the percentage

pc,

logical, whether to display the percentage of N that n comprises

oo,

logical, whether to display n/N as a fraction

use.sci,

logical, whether to allow scientific notation for small/large percentages.

Value

A string showing the fraction n/N and percentage (or just one of these)

Examples

1
2
3
4
out.of(345,12144)
out.of(345,12144,pc=FALSE)
out.of(3,10^6,digits=6,oo=FALSE)
out.of(3,10^6,digits=6,oo=FALSE,use.sci=TRUE)


NCmisc documentation built on May 20, 2017, 2:35 a.m.
Search within the NCmisc package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.