Cast x to a deb_decimal vector.

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 numeric
deb_as_decimal(x, unit = c("l", "s", "d"), bases = c(20, 12), ...)

# S3 method for logical
deb_as_decimal(x, unit = c("l", "s", "d"), bases = c(20, 12), ...)

# S3 method for list
deb_as_decimal(x, unit = c("l", "s", "d"), 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.

Value

A deb_decimal vector.

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.

See also

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 numeric vector to deb_decimal y <- c(5.825, 3.25, 22/3) deb_as_decimal(y)
#> <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(y, unit = "s", bases = c(60, 16))
#> <deb_decimal[3]> #> [1] 5.825000 3.250000 7.333333 #> # Unit: solidus #> # Bases: 60s 16d
# Cast a list to deb_lsd provides an alternate # to deb_lsd() %>% deb_decimal() list(c(5, 12, 3), c(13, 8, 11), c(7, 16, 0)) %>% deb_as_decimal()
#> <deb_decimal[3]> #> [1] 5.61250 13.44583 7.80000 #> # Unit: libra #> # Bases: 20s 12d