Create a vector of class deb_decimal to integrate non-decimal currencies and other measurements that use tripartite or tetrapartite units into standardized forms of analysis provided by R.

## Usage

deb_decimal(x = double(), unit = c("l", "s", "d", "f"), bases = c(20, 12))

## Arguments

x

A numeric vector representing the decimalized values of either tripartite or tetrapartite values.

unit

A character vector of length one indicating the unit for the decimalized values, either "l" (libra, the default), "s" (solidus), "d" (denarius), or "f" (farthing). "f" is only valid if the bases argument is a numeric vector of length 3 (a tetrapartite value).

bases

Numeric vector of length 2 or 3 used to specify the bases for the solidus or s, denarius or d, and optionally the farthing or f units. Default is c(20, 12), which conforms to the most widely used tripartite system of 1 pound = 20 shillings and 1 shilling = 12 pence.

## Value

Returns a vector of class deb_decimal.

## Details

The deb_decimal class and the debkeepr package use the nomenclature of l, s, and d to represent the tripartite system of pounds, shillings, and pence units. The abbreviations derive from the Latin terms libra, solidus, and denarius. In the 8th century a solidus came to represent 12 denarii coins, and, for a time at least, 240 denarii were made from one libra or pound of silver. The custom of counting coins in dozens (solidi) and scores of dozens (librae) spread throughout the Carolingian Empire and became ingrained in much of Europe. However, a variety of accounting systems arose at different times that used other bases for the solidus and denarius units and even additional units. The deb_decimal class decimalizes either tripartite or tetrapartite values. The bases attribute makes it possible to specify the bases for the solidus, denarius, and optionally farthing units. The unit attribute identifies the decimalized unit: either libra, solidus, denarius, or farthing.

deb_decimal vectors can either be tripartite, like deb_lsd, or tetrapartite, like deb_tetra. These two kinds of deb_decimal vectors are distinguished by the length of bases attribute (2 for tripartite and 3 for tetrapartite) and the addition of the farthing unit for tetrapartite. If the solidus and denarius bases are equal, tripartite and tetrapartite deb_decimal vectors can be combined. The result is a deb_decimal vector with tripartite bases.

The deb_decimal class works in concert with the deb_lsd and deb_tetra classes. These classes maintain the tripartite (deb_lsd) and tetrapartite (deb_tetra) unit structure of non-decimal currencies and values. See deb_lsd() and deb_tetra().

## Examples


# deb_decimal with tripartite units
deb_decimal(c(5.25, 3.825, 8.5))
#> <deb_decimal[3]>
#> [1] 5.250 3.825 8.500
#> # Unit: libra
#> # Bases: 20s 12d

# Set the unit of the deb_decimal vector
deb_decimal(c(105, 76.5, 170), unit = "s")
#> <deb_decimal[3]>
#> [1] 105.0  76.5 170.0
#> # Unit: solidus
#> # Bases: 20s 12d
deb_decimal(c(1260, 918, 240), unit = "d")
#> <deb_decimal[3]>
#> [1] 1260  918  240
#> # Unit: denarius
#> # Bases: 20s 12d

# Set the bases of the deb_decimal vector
deb_decimal(c(5.25, 3.825, 8.5), bases = c(60, 16))
#> <deb_decimal[3]>
#> [1] 5.250 3.825 8.500
#> # Unit: libra
#> # Bases: 60s 16d

# Create a prototype or vector of length 0
deb_decimal()
#> <deb_decimal[0]>
#> # Unit: libra
#> # Bases: 20s 12d

# To create a tetrapartite value, provide numeric vector
# of length 3 to bases argument
deb_decimal(c(5.11875, 3.234375, 8.2875),
bases = c(20, 12, 4))
#> <deb_decimal[3]>
#> [1] 5.118750 3.234375 8.287500
#> # Unit: libra
#> # Bases: 20s 12d 4f
deb_decimal(c(4914, 3105, 7956),
unit = "f",
bases = c(20, 12, 4))
#> <deb_decimal[3]>
#> [1] 4914 3105 7956
#> # Unit: farthing
#> # Bases: 20s 12d 4f