Cast x
to a deb_decimal
vector.
Usage
deb_as_decimal(x, ...)
# S3 method for default
deb_as_decimal(x, ...)
# S3 method for deb_decimal
deb_as_decimal(x, ...)
# S3 method for deb_lsd
deb_as_decimal(x, unit = c("l", "s", "d"), ...)
# S3 method for deb_tetra
deb_as_decimal(x, unit = c("l", "s", "d", "f"), ...)
# S3 method for numeric
deb_as_decimal(x, unit = c("l", "s", "d", "f"), bases = c(20, 12), ...)
# S3 method for logical
deb_as_decimal(x, unit = c("l", "s", "d", "f"), bases = c(20, 12), ...)
# S3 method for list
deb_as_decimal(x, unit = c("l", "s", "d", "f"), bases = c(20, 12), ...)
Arguments
- x
An object to coerce to
deb_decimal
.- ...
Arguments passed on to further methods.
- unit
A character vector of length one indicating the unit for the decimalized values, either
"l"
(libra, the default),"s"
(solidus), or"d"
(denarius).- bases
Numeric vector of length 2 used to specify the bases for the solidus or s and denarius or d units. Default is
c(20, 12)
, which conforms to the most widely used system of 1 pound = 20 shillings and 1 shilling = 12 pence.
Details
Like deb_as_lsd()
, deb_as_decimal()
provides a method to
cast a list of numeric vectors of length 3 to deb_decimal
. This may be
helpful because the data is input by the value instead of by the unit.
Examples
# Cast a deb_lsd vector to deb_decimal
x <- deb_lsd(l = c(5, 3, 7),
s = c(16, 5, 6),
d = c(6, 0, 8))
deb_as_decimal(x)
#> <deb_decimal[3]>
#> [1] 5.825000 3.250000 7.333333
#> # Unit: libra
#> # Bases: 20s 12d
# Bases are automatically applied when
# casting from deb_lsd to deb_decimal
x2 <- deb_lsd(l = c(5, 3, 7),
s = c(16, 5, 6),
d = c(6, 0, 8),
bases = c(60, 16))
deb_as_decimal(x2)
#> <deb_decimal[3]>
#> [1] 5.272917 3.083333 7.108333
#> # Unit: libra
#> # Bases: 60s 16d
# Cast a deb_tetra vector to deb_decimal
# Bases are automatically applied, creating
# a deb_decimal vector with three bases units.
y <- deb_tetra(l = c(5, 13, 7),
s = c(12, 8, 16),
d = c(3, 11, 0),
f = c(1, 3, 2))
deb_as_decimal(y)
#> <deb_decimal[3]>
#> [1] 5.613542 13.448958 7.802083
#> # Unit: libra
#> # Bases: 20s 12d 4f
# Cast a numeric vector to deb_decimal
z <- c(5.825, 3.25, 22/3)
deb_as_decimal(z)
#> <deb_decimal[3]>
#> [1] 5.825000 3.250000 7.333333
#> # Unit: libra
#> # Bases: 20s 12d
# Use the unit and bases arguments to specify
# the unit and apply non-default bases
deb_as_decimal(z, unit = "s", bases = c(60, 16))
#> <deb_decimal[3]>
#> [1] 5.825000 3.250000 7.333333
#> # Unit: solidus
#> # Bases: 60s 16d
# Casting a list to deb_decimal provides an
# alternative to get lsd values to deb_decimal.
lsd_list <- list(c(5, 12, 3),
c(13, 8, 11),
c(7, 16, 0))
deb_as_decimal(lsd_list)
#> <deb_decimal[3]>
#> [1] 5.61250 13.44583 7.80000
#> # Unit: libra
#> # Bases: 20s 12d