-
Notifications
You must be signed in to change notification settings - Fork 114
/
style_percent.Rd
58 lines (51 loc) · 1.5 KB
/
style_percent.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/style_percent.R
\name{style_percent}
\alias{style_percent}
\title{Style percentages}
\usage{
style_percent(
x,
digits = 0,
big.mark = ifelse(decimal.mark == ",", " ", ","),
decimal.mark = getOption("OutDec"),
prefix = "",
suffix = "",
symbol,
...
)
}
\arguments{
\item{x}{numeric vector of percentages}
\item{digits}{number of digits to round large percentages (i.e. greater than 10\%).
Smaller percentages are rounded to \code{digits + 1} places.
Default is \code{0}}
\item{big.mark}{(\code{string})\cr
Character used between every 3 digits to separate
hundreds/thousands/millions/etc.
Default is \code{","}, except when \code{decimal.mark = ","} when the default is a space.}
\item{decimal.mark}{(\code{string})\cr
The character to be used to indicate the numeric decimal point.
Default is \code{"."} or \code{getOption("OutDec")}}
\item{prefix}{(\code{string})\cr
Additional text to display before the number.}
\item{suffix}{(\code{string})\cr
Additional text to display after the number.}
\item{symbol}{Logical indicator to include percent symbol in output.
Default is \code{FALSE}.}
\item{...}{Arguments passed on to \code{base::format()}}
}
\value{
A character vector of styled percentages
}
\description{
Style percentages
}
\examples{
percent_vals <- c(-1, 0, 0.0001, 0.005, 0.01, 0.10, 0.45356, 0.99, 1.45)
style_percent(percent_vals)
style_percent(percent_vals, suffix = "\%", digits = 1)
}
\author{
Daniel D. Sjoberg
}