cast-tetra {debkeepr} | R Documentation |
Cast to deb_tetra
Description
Cast x
to a deb_tetra
vector.
Usage
deb_as_tetra(x, ...)
## Default S3 method:
deb_as_tetra(x, ...)
## S3 method for class 'deb_tetra'
deb_as_tetra(x, ...)
## S3 method for class 'deb_lsd'
deb_as_tetra(x, f, ...)
## S3 method for class 'deb_decimal'
deb_as_tetra(x, f, ...)
## S3 method for class 'numeric'
deb_as_tetra(x, bases = c(20, 12, 4), ...)
## S3 method for class 'logical'
deb_as_tetra(x, bases = c(20, 12, 4), ...)
## S3 method for class 'list'
deb_as_tetra(x, bases = c(20, 12, 4), ...)
Arguments
x |
An object to coerce to |
... |
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
|
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.
Value
A deb_tetra
vector.
See Also
deb_as_lsd()
and deb_as_decimal()
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_as_tetra(lsd2, f = 8)
# 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)
# Use "f" argument to cast from tripartite deb_decimal
# to deb_tetra
d2 <- deb_decimal(x)
deb_as_tetra(d2, f = 4)
# Cast a numeric vector to deb_tetra
deb_as_tetra(x)
# Use the bases argument to apply non-default bases
deb_as_tetra(x, bases = c(60, 16, 8))
# 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(l = c(5, 13, 7),
s = c(12, 8, 16),
d = c(3, 11, 0),
f = c(2, 1, 3))