Learn R Programming

debkeepr (version 0.1.1)

deb_convert_unit: Convert the unit of deb_decimal vectors

Description

Convert the unit attribute of deb_decimal vectors.

Usage

deb_convert_unit(x, to = c("l", "s", "d", "f"))

Value

A deb_decimal vector with a converted unit attribute.

Arguments

x

A vector of class deb_decimal.

to

A character vector of length one indicating the unit to be converted to. Choice of "l" (libra, the default), "s" (solidus), "d" (denarius), or "f" (farthing).

Details

deb_convert_unit() converts the unit of a deb_decimal vector to either "l", "s", "d", or optionally "f" if the vector has tetrapartite bases. This changes the representation of the vector, but the value remains equivalent.

Examples

Run this code

x <- deb_decimal(c(8.825, 15.125, 3.65))
y <- deb_decimal(c(56.45, 106.525, 200.4), unit = "s")
z <- deb_decimal(c(8472, 14520,  3504),
                 unit = "f",
                 bases = c(20, 12, 4))

deb_convert_unit(x, to = "s")
deb_convert_unit(x, to = "d")
deb_convert_unit(y, to = "l")
deb_convert_unit(y, to = "d")
deb_convert_unit(z, to = "l")
deb_convert_unit(z, to = "s")

Run the code above in your browser using DataLab