Skip to contents

Convert bases of deb_lsd, deb_tetra, and deb_decimal vectors

Usage

deb_convert_bases(x, to)

# S3 method for default
deb_convert_bases(x, to)

# S3 method for deb_lsd
deb_convert_bases(x, to)

# S3 method for deb_decimal
deb_convert_bases(x, to)

# S3 method for deb_tetra
deb_convert_bases(x, to)

Arguments

x

A vector of class deb_lsd, deb_tetra, or deb_decimal.

to

Numeric vector of length 2 or 3, representing the bases for the solidus, denarius, and optionally farthing units to be converted to.

Value

A vector of the same class as x with converted bases attribute.

Details

deb_convert_bases() is the only way to change the bases of the solidus, denarius, and farthing units associated with vectors of class deb_lsd, deb_tetra, and deb_decimal. It also provides a means to convert between tripartite and tetrapartite bases with deb_decimal vectors.

If x is a deb_decimal vector with tetrapartite bases and unit "f" and to is a numeric vector of length 2, the unit will be converted to "d".

Examples


lsd <- deb_lsd(5, 3, 8)
dec <- deb_decimal(8.825)
dec_tetra <- deb_decimal(1.840625, bases = c(20, 12, 4))
tetra <- deb_tetra(1, 16, 9, 3)

deb_convert_bases(lsd, to = c(60, 16))
#> <deb_lsd[1]>
#> [1] 5:11s:0d
#> # Bases: 60s 16d
deb_convert_bases(dec, to = c(60, 16))
#> <deb_decimal[1]>
#> [1] 8.825
#> # Unit: libra
#> # Bases: 60s 16d
deb_convert_bases(dec_tetra, c(60, 16, 8))
#> <deb_decimal[1]>
#> [1] 1.840625
#> # Unit: libra
#> # Bases: 60s 16d 8f
deb_convert_bases(tetra, to = c(60, 16, 8))
#> <deb_tetra[1]>
#> [1] 1:50s:7d:0f
#> # Bases: 60s 16d 8f

# Convert between tripartite and tetrapartite bases
deb_convert_bases(dec, to = c(60, 16, 8))
#> <deb_decimal[1]>
#> [1] 8.825
#> # Unit: libra
#> # Bases: 60s 16d 8f
deb_convert_bases(dec_tetra, to = c(20, 12))
#> <deb_decimal[1]>
#> [1] 1.840625
#> # Unit: libra
#> # Bases: 20s 12d