Skip to contents

Cast x to a deb_tetra vector.

Usage

deb_as_tetra(x, ...)

# S3 method for default
deb_as_tetra(x, ...)

# S3 method for deb_tetra
deb_as_tetra(x, ...)

# S3 method for deb_lsd
deb_as_tetra(x, f, ...)

# S3 method for deb_decimal
deb_as_tetra(x, f, ...)

# S3 method for numeric
deb_as_tetra(x, bases = c(20, 12, 4), ...)

# S3 method for logical
deb_as_tetra(x, bases = c(20, 12, 4), ...)

# S3 method for list
deb_as_tetra(x, bases = c(20, 12, 4), ...)

Arguments

x

An object to coerce to deb_tetra.

...

Arguments passed on to further methods.

f

Integer of length 1 to represent the base of the farthing unit. Must be provided to cast from deb_lsd or deb_decimal vectors with tripartite bases to deb_tetra.

bases

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

Value

A deb_tetra vector.

Details

Casting a list of numeric vectors of length 4 to deb_tetra provides an alternate way to create a deb_tetra vector than deb_tetra(). This method may be helpful because the data is input by the value instead of by the unit.

Examples


# To cast from deb_lsd to deb_tetra an "f" unit must be supplied

# Compare
lsd1 <- deb_lsd(8, 12, 4)
lsd2 <- deb_lsd(8, 12, 4, bases = c(60, 16))

deb_as_tetra(lsd1, f = 4)
#> <deb_tetra[1]>
#> [1] 8:12s:4d:0f
#> # Bases: 20s 12d 4f
deb_as_tetra(lsd2, f = 8)
#> <deb_tetra[1]>
#> [1] 8:12s:4d:0f
#> # Bases: 60s 16d 8f

# Cast a deb_decimal vector with four units to deb_tetra.
# Bases are automatically applied when casting from
# tetrapartite deb_decimal to deb_tetra.
x <- c(5.11875, 3.76875, 25/3)
d1 <- deb_decimal(x, bases = c(20, 12, 4))
deb_as_tetra(d1)
#> <deb_tetra[3]>
#> [1] 5:2s:4d:2f  3:15s:4d:2f 8:6s:8d:0f 
#> # Bases: 20s 12d 4f

# Use "f" argument to cast from tripartite deb_decimal
# to deb_tetra
d2 <- deb_decimal(x)
deb_as_tetra(d2, f = 4)
#> <deb_tetra[3]>
#> [1] 5:2s:4d:2f  3:15s:4d:2f 8:6s:8d:0f 
#> # Bases: 20s 12d 4f

# Cast a numeric vector to deb_tetra
deb_as_tetra(x)
#> <deb_tetra[3]>
#> [1] 5:2s:4d:2f  3:15s:4d:2f 8:6s:8d:0f 
#> # Bases: 20s 12d 4f

# Use the bases argument to apply non-default bases
deb_as_tetra(x, bases = c(60, 16, 8))
#> <deb_tetra[3]>
#> [1] 5:7s:2d:0f  3:46s:2d:0f 8:20s:0d:0f
#> # Bases: 60s 16d 8f

# Casting a list to deb_tetra provides an alternate
# to deb_tetra(). This can be helpful for legibility.
# Compare:

deb_as_tetra(
  list(c(5, 12, 3, 2),
       c(13, 8, 11, 1),
       c(7, 16, 0, 3))
  )
#> <deb_tetra[3]>
#> [1] 5:12s:3d:2f  13:8s:11d:1f 7:16s:0d:3f 
#> # Bases: 20s 12d 4f

deb_tetra(l = c(5, 13, 7),
          s = c(12, 8, 16),
          d = c(3, 11, 0),
          f = c(2, 1, 3))
#> <deb_tetra[3]>
#> [1] 5:12s:3d:2f  13:8s:11d:1f 7:16s:0d:3f 
#> # Bases: 20s 12d 4f