Skip to contents

Cast x to a deb_lsd vector.

Usage

deb_as_lsd(x, ...)

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

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

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

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

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

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

# S3 method for 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.

Value

A deb_lsd vector.

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.

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)
#> <deb_lsd[3]>
#> [1] 5:16s:6d 3:5s:0d  7:6s:8d 
#> # Bases: 20s 12d

# Bases are automatically applied when
# casting from deb_decimal to deb_lsd
d2 <- deb_decimal(x, bases = c(60, 16))
deb_as_lsd(d2)
#> <deb_lsd[3]>
#> [1] 5:49s:8d 3:15s:0d 7:20s:0d
#> # Bases: 60s 16d

# 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)
#> <deb_lsd[3]>
#> [1] 5:12s:3.25d  13:8s:11.75d 7:16s:0.5d  
#> # Bases: 20s 12d

# Cast a numeric vector to deb_lsd
deb_as_lsd(x)
#> <deb_lsd[3]>
#> [1] 5:16s:6d 3:5s:0d  7:6s:8d 
#> # Bases: 20s 12d

# Use the bases argument to apply non-default bases
deb_as_lsd(x, bases = c(60, 16))
#> <deb_lsd[3]>
#> [1] 5:49s:8d 3:15s:0d 7:20s:0d
#> # Bases: 60s 16d

# 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[3]>
#> [1] 5:12s:3d  13:8s:11d 7:16s:0d 
#> # Bases: 20s 12d

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