text {debkeepr} | R Documentation |
Format deb_lsd
, deb_decimal
, and deb_tetra
vectors as text
Description
Flexible way to format deb_lsd
, deb_decimal
, and deb_tetra
vectors
for use as labels or text.
Usage
deb_text(x, ...)
## Default S3 method:
deb_text(x, ...)
## S3 method for class 'deb_lsd'
deb_text(
x,
digits = 0,
currency = "£",
l.mark = "",
s.mark = "s.",
d.mark = "d.",
sep = " ",
big.mark = ",",
decimal.mark = ".",
suffix = "",
...
)
## S3 method for class 'deb_decimal'
deb_text(
x,
digits = 0,
currency = "£",
big.mark = ",",
decimal.mark = ".",
suffix = "",
...
)
## S3 method for class 'deb_tetra'
deb_text(
x,
digits = 0,
currency = "£",
l.mark = "",
s.mark = "s.",
d.mark = "d.",
f.mark = "f.",
sep = " ",
big.mark = ",",
decimal.mark = ".",
suffix = "",
...
)
Arguments
x |
A vector of class |
... |
Arguments passed on to further methods. |
digits |
Desired number of digits after the decimal mark to which to
round the numeric values. Default is |
currency |
Character used for the currency mark. Default is pound sign. |
l.mark |
Character used following the pounds (l) unit.
Default is |
s.mark |
Character used following the shillings (s) unit.
Default is |
d.mark |
Character used following the pence (d) unit.
Default is |
sep |
Character to separate pounds, shillings, pence, and optionally
farthing units. Default is |
big.mark |
Character used to mark intervals to the left of the decimal
mark. Default is |
decimal.mark |
Character used for decimal mark. Default is |
suffix |
Character placed after the values. Default is |
f.mark |
Character used following the farthing (f) unit with
tetrapartite values. Default is |
Details
deb_text
is similar to as.character()
in that both return a character
vector of the values of deb_lsd
, deb_decimal
, and deb_tetra
vectors.
However, as.character()
uses the normal printing method for these vectors.
deb_text()
provides a convenient way to nicely format deb_lsd
,
deb_decimal
, and deb_tetra
vectors for use as text or labels with
options for customization.
deb_text()
uses formatC()
to format the numeric values of x
. Numbers
are printed in non-scientific format and trailing zeros are dropped.
All character vector arguments should be length 1.
Value
A Character vector of formatted values.
See Also
formatC()
for further options passed to ...
.
Examples
lsd <- deb_lsd(l = c(10000, 0, -10000),
s = c(8, 0, -8),
d = c(5.8252, 0, -5.8252))
dec <- deb_decimal(c(10000.8252, 0, -10000.8252))
tetra <- deb_tetra(l = c(10000, 0, -10000),
s = c(8, 0, -8),
d = c(5, 0, -5),
f = c(2.8252, 0, -2.8252))
deb_text(lsd)
deb_text(dec)
deb_text(tetra)
# Compact format for deb_lsd with suffix to distinguish currency
deb_text(lsd, s.mark = "", d.mark = "",
sep = ".", suffix = " Flemish")
# Control the number of digits
deb_text(lsd, digits = 3)
deb_text(dec, digits = 3)
deb_text(tetra, digits = 3)
# Change big mark and decimal mark
deb_text(lsd, digits = 4, big.mark = ".", decimal.mark = ",")
deb_text(dec, digits = 4, big.mark = ".", decimal.mark = ",")
deb_text(tetra, digits = 4, big.mark = ".", decimal.mark = ",")