Math and Summary group of functions with deb_lsd and deb_tetra vectors. Implemented functions:

• Summary group: sum(), any(), and all().

• Math group: abs(), round(), signif(), ceiling(), floor(), trunc(), cummax(), cummin(), and cumsum().

• Additional generics: mean(), is.nan(), is.finite(), and is.infinite().

All other functions from the groups not currently implemented, including median(), quantile(), and summary().

Arguments

x

An vector of class deb_lsd or deb_tetra.

...

deb_lsd or deb_tetra vectors in sum() and arguments passed on to further methods in mean().

na.rm

Logical. Should missing values (including NaN) be removed?

digits

Integer. Indicating the number of decimal places (round()) or significant digits (signif()) to be used.

Value

A deb_lsd or deb_tetra vector with normalized values.

Details

sum() and cumsum() return a normalized deb_lsd or deb_tetra values.

Round family of functions only affect the denarius (d) unit of a deb_lsd value and the farthing (f) unit of deb_tetra value. All values are normalized.

If you need a wider implementation of Math and Summary group functions, use a deb_decimal vector. However, median(), quantile(), and summary() are also not currently implemented for deb_decimal vectors. To use these functions cast deb_lsd, deb_tetra, and deb_decimal vectors to numeric.

Examples

x <- deb_lsd(l = c(5, 8, 12),
s = c(16, 6, 13),
d = c(6, 11, 0))
y <- deb_tetra(l = c(5, 8, 12),
s = c(16, 6, 13),
d = c(6, 11, 0),
f = c(3, 2, 3))

# All values are normalized with sum and cumsum
sum(x)
#> <deb_lsd[1]>
#> [1] 26:16s:5d
#> # Bases: 20s 12d
sum(y)
#> <deb_tetra[1]>
#> [1] 26:16s:7d:0f
#> # Bases: 20s 12d 4f
cumsum(x)
#> <deb_lsd[3]>
#> [1] 5:16s:6d  14:3s:5d  26:16s:5d
#> # Bases: 20s 12d
cumsum(y)
#> <deb_tetra[3]>
#> [1] 5:16s:6d:3f  14:3s:6d:1f  26:16s:7d:0f
#> # Bases: 20s 12d 4f
mean(x)
#> <deb_lsd[1]>
#> [1] 8:18s:9.667d
#> # Bases: 20s 12d
mean(y)
#> <deb_tetra[1]>
#> [1] 8:18s:10d:1.333f
#> # Bases: 20s 12d 4f

# Round family on deb_lsd affects the denarius unit
x2 <- deb_lsd(5, 12, 5.8365)
y2 <- deb_tetra(5, 12, 8, 4.125)
round(x2)
#> <deb_lsd[1]>
#> [1] 5:12s:6d
#> # Bases: 20s 12d
round(y2)
#> <deb_tetra[1]>
#> [1] 5:12s:9d:0f
#> # Bases: 20s 12d 4f
round(x2, digits = 2)
#> <deb_lsd[1]>
#> [1] 5:12s:5.84d
#> # Bases: 20s 12d
signif(x2, digits = 2)
#> <deb_lsd[1]>
#> [1] 5:12s:5.8d
#> # Bases: 20s 12d
ceiling(x2)
#> <deb_lsd[1]>
#> [1] 5:12s:6d
#> # Bases: 20s 12d
ceiling(y2)
#> <deb_tetra[1]>
#> [1] 5:12s:9d:1f
#> # Bases: 20s 12d 4f
floor(x2)
#> <deb_lsd[1]>
#> [1] 5:12s:5d
#> # Bases: 20s 12d
floor(y2)
#> <deb_tetra[1]>
#> [1] 5:12s:9d:0f
#> # Bases: 20s 12d 4f
trunc(x2)
#> <deb_lsd[1]>
#> [1] 5:12s:5d
#> # Bases: 20s 12d
trunc(y2)
#> <deb_tetra[1]>
#> [1] 5:12s:9d:0f
#> # Bases: 20s 12d 4f

# The returned values are normalized whether
# they are positive or negative
x3 <- deb_lsd(9, 19, 11.825)
x4 <- deb_lsd(-9, -19, -11.825)
round(x3)
#> <deb_lsd[1]>
#> [1] 10:0s:0d
#> # Bases: 20s 12d
round(x3, digits = 1)
#> <deb_lsd[1]>
#> [1] 9:19s:11.8d
#> # Bases: 20s 12d

ceiling(x3)
#> <deb_lsd[1]>
#> [1] 10:0s:0d
#> # Bases: 20s 12d
floor(x4)
#> <deb_lsd[1]>
#> [1] -10:0s:0d
#> # Bases: 20s 12d

trunc(x3)
#> <deb_lsd[1]>
#> [1] 9:19s:11d
#> # Bases: 20s 12d
trunc(x4)
#> <deb_lsd[1]>
#> [1] -9:-19s:-11d
#> # Bases: 20s 12d

`