cast-lsd {debkeepr}R Documentation

Cast to deb_lsd

Description

Cast x to a deb_lsd vector.

Usage

deb_as_lsd(x, ...)

## Default S3 method:
deb_as_lsd(x, ...)

## S3 method for class 'deb_lsd'
deb_as_lsd(x, ...)

## S3 method for class 'deb_decimal'
deb_as_lsd(x, ...)

## S3 method for class 'deb_tetra'
deb_as_lsd(x, ...)

## S3 method for class 'numeric'
deb_as_lsd(x, bases = c(20, 12), ...)

## S3 method for class 'logical'
deb_as_lsd(x, bases = c(20, 12), ...)

## S3 method for class 'list'
deb_as_lsd(x, bases = c(20, 12), ...)

Arguments

x

An object to coerce to deb_lsd.

...

Arguments passed on to further methods.

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.

Details

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

Value

A deb_lsd vector.

See Also

deb_as_decimal() and deb_as_tetra()

Examples


# Cast a deb_decimal vector to deb_lsd
x <- c(5.825, 3.25, 22/3)
d1 <- deb_decimal(x)
deb_as_lsd(d1)

# Bases are automatically applied when
# casting from deb_decimal to deb_lsd
d2 <- deb_decimal(x, bases = c(60, 16))
deb_as_lsd(d2)

# Cast a deb_tetra vector to deb_lsd
# This removes the 'f' or farthings unit.
y <- deb_tetra(l = c(5, 13, 7),
               s = c(12, 8, 16),
               d = c(3, 11, 0),
               f = c(1, 3, 2))
deb_as_lsd(y)

# Cast a numeric vector to deb_lsd
deb_as_lsd(x)

# Use the bases argument to apply non-default bases
deb_as_lsd(x, bases = c(60, 16))

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

deb_as_lsd(
  list(c(5, 12, 3),
       c(13, 8, 11),
       c(7, 16, 0))
  )

deb_lsd(l = c(5, 13, 7),
        s = c(12, 8, 16),
        d = c(3, 11, 0))


[Package debkeepr version 0.1.1 Index]