Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Analysis of Non-Decimal Currencies and Double-Entry Bookkeeping
Version:0.1.1
Description:Analysis of historical non-decimal currencies and value systems that use tripartite or tetrapartite systems such as pounds, shillings, and pence. It introduces new vector classes to represent non-decimal currencies, making them compatible with numeric classes, and provides functions to work with these classes in data frames in the context of double-entry bookkeeping.
License:MIT + file LICENSE
URL:https://github.com/jessesadler/debkeepr,https://jessesadler.github.io/debkeepr/
BugReports:https://github.com/jessesadler/debkeepr/issues
Depends:R (≥ 3.5)
Imports:cli (≥ 3.4.0), dplyr (≥ 1.0.0), magrittr, methods, rlang (≥1.1.0), tibble (≥ 3.0.0), vctrs (≥ 0.5.2), zeallot
Suggests:covr, ggplot2, ggraph, igraph, knitr, rmarkdown, roxygen2,scales (≥ 1.1.0), testthat (≥ 3.1.3)
VignetteBuilder:knitr
Config/testthat/edition:3
Encoding:UTF-8
LazyData:true
RoxygenNote:7.2.3
NeedsCompilation:no
Packaged:2023-03-21 21:54:06 UTC; jessesadler
Author:Jesse SadlerORCID iD [aut, cre, cph]
Maintainer:Jesse Sadler <jrsadler@icloud.com>
Repository:CRAN
Date/Publication:2023-03-22 09:00:10 UTC

debkeepr: Analysis of Non-Decimal Currencies and Double-Entry Bookkeeping

Description

logo

Analysis of historical non-decimal currencies and value systems that use tripartite or tetrapartite systems such as pounds, shillings, and pence. It introduces new vector classes to represent non-decimal currencies, making them compatible with numeric classes, and provides functions to work with these classes in data frames in the context of double-entry bookkeeping.

Author(s)

Maintainer: Jesse Sadlerjrsadler@icloud.com (ORCID) [copyright holder]

See Also

Useful links:


Pipe operator

Description

Seemagrittr::%>% for details.

Usage

lhs %>% rhs

Arguments

lhs

A value or the magrittr placeholder.

rhs

A function call using the magrittr semantics.

Value

The result of callingrhs(lhs).


Unpacking assignment

Description

See%<-% for more details.

Usage

x %<-% value

Value

Invisibly returnsvalue.


Arithmetic operations for debkeepr

Description

Arithmetic operations for debkeepr

Usage

## S3 method for class 'deb_lsd'vec_arith(op, x, y, ...)## Default S3 method:vec_arith.deb_lsd(op, x, y, ...)## S3 method for class 'deb_lsd'vec_arith.deb_lsd(op, x, y, ...)## S3 method for class 'numeric'vec_arith.deb_lsd(op, x, y, ...)## S3 method for class 'deb_lsd'vec_arith.numeric(op, x, y, ...)## S3 method for class 'MISSING'vec_arith.deb_lsd(op, x, y, ...)## S3 method for class 'deb_decimal'vec_arith(op, x, y, ...)## Default S3 method:vec_arith.deb_decimal(op, x, y, ...)## S3 method for class 'deb_decimal'vec_arith.deb_decimal(op, x, y, ...)## S3 method for class 'numeric'vec_arith.deb_decimal(op, x, y, ...)## S3 method for class 'deb_decimal'vec_arith.numeric(op, x, y, ...)## S3 method for class 'MISSING'vec_arith.deb_decimal(op, x, y, ...)## S3 method for class 'deb_tetra'vec_arith(op, x, y, ...)## Default S3 method:vec_arith.deb_tetra(op, x, y, ...)## S3 method for class 'deb_tetra'vec_arith.deb_tetra(op, x, y, ...)## S3 method for class 'numeric'vec_arith.deb_tetra(op, x, y, ...)## S3 method for class 'deb_tetra'vec_arith.numeric(op, x, y, ...)## S3 method for class 'MISSING'vec_arith.deb_tetra(op, x, y, ...)## S3 method for class 'deb_decimal'vec_arith.deb_lsd(op, x, y, ...)## S3 method for class 'deb_lsd'vec_arith.deb_decimal(op, x, y, ...)## S3 method for class 'deb_tetra'vec_arith.deb_lsd(op, x, y, ...)## S3 method for class 'deb_lsd'vec_arith.deb_tetra(op, x, y, ...)## S3 method for class 'deb_decimal'vec_arith.deb_tetra(op, x, y, ...)## S3 method for class 'deb_tetra'vec_arith.deb_decimal(op, x, y, ...)

Arguments

op

Arithmetic operation.

x,y

Vectors.

...

For future expansion

Value

Adeb_lsd,deb_tetra,deb_decimal ornumeric vectordepending on the inputs and arithmetic operator.


Cast todeb_decimal

Description

Castx to adeb_decimal vector.

Usage

deb_as_decimal(x, ...)## Default S3 method:deb_as_decimal(x, ...)## S3 method for class 'deb_decimal'deb_as_decimal(x, ...)## S3 method for class 'deb_lsd'deb_as_decimal(x, unit = c("l", "s", "d"), ...)## S3 method for class 'deb_tetra'deb_as_decimal(x, unit = c("l", "s", "d", "f"), ...)## S3 method for class 'numeric'deb_as_decimal(x, unit = c("l", "s", "d", "f"), bases = c(20, 12), ...)## S3 method for class 'logical'deb_as_decimal(x, unit = c("l", "s", "d", "f"), bases = c(20, 12), ...)## S3 method for class 'list'deb_as_decimal(x, unit = c("l", "s", "d", "f"), bases = c(20, 12), ...)

Arguments

x

An object to coerce todeb_decimal.

...

Arguments passed on to further methods.

unit

A character vector of length one indicating the unit for thedecimalized values, either"l" (libra, the default),"s" (solidus),or"d" (denarius).

bases

Numeric vector of length 2 used to specify the bases for thesolidus or s and denarius or d units. Default isc(20, 12), whichconforms to the most widely used system of 1 pound = 20 shillings and1 shilling = 12 pence.

Details

Likedeb_as_lsd(),deb_as_decimal() provides a method tocast a list of numeric vectors of length 3 todeb_decimal. This may behelpful because the data is input by the value instead of by the unit.

Value

Adeb_decimal vector.

See Also

deb_as_lsd() anddeb_as_tetra()

Examples

# Cast a deb_lsd vector to deb_decimalx <- deb_lsd(l = c(5, 3, 7),             s = c(16, 5, 6),             d = c(6, 0, 8))deb_as_decimal(x)# Bases are automatically applied when# casting from deb_lsd to deb_decimalx2 <- deb_lsd(l = c(5, 3, 7),              s = c(16, 5, 6),              d = c(6, 0, 8),              bases = c(60, 16))deb_as_decimal(x2)# Cast a deb_tetra vector to deb_decimal# Bases are automatically applied, creating# a deb_decimal vector with three bases units.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_decimal(y)# Cast a numeric vector to deb_decimalz <- c(5.825, 3.25, 22/3)deb_as_decimal(z)# Use the unit and bases arguments to specify# the unit and apply non-default basesdeb_as_decimal(z, unit = "s", bases = c(60, 16))# Casting a list to deb_decimal provides an# alternative to get lsd values to deb_decimal.lsd_list <- list(c(5, 12, 3),                 c(13, 8, 11),                 c(7, 16, 0))deb_as_decimal(lsd_list)

Cast todeb_lsd

Description

Castx to adeb_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 todeb_lsd.

...

Arguments passed on to further methods.

bases

Numeric vector of length 2 used to specify the bases for thesolidus or s and denarius or d units. Default isc(20, 12), whichconforms to the most widely used system of 1 pound = 20 shillings and1 shilling = 12 pence.

Details

Casting a list of numeric vectors of length 3 todeb_lsdprovides an alternate way to create adeb_lsd vector thandeb_lsd().This method may be helpful because the data is input by the value insteadof by the unit.

Value

Adeb_lsd vector.

See Also

deb_as_decimal() anddeb_as_tetra()

Examples

# Cast a deb_decimal vector to deb_lsdx <- 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_lsdd2 <- 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_lsddeb_as_lsd(x)# Use the bases argument to apply non-default basesdeb_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))

Cast todeb_tetra

Description

Castx to adeb_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 todeb_tetra.

...

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 withtripartite bases to deb_tetra.

bases

Numeric vector of length 3 used to specify the bases for thesolidus or s, denarius or d, and farthing or f units. Default isc(20, 12, 4), which conforms to the English system of 1 pound =20 shillings, 1 shilling = 12 pence, and 1 pence = 4 farthing.

Details

Casting a list of numeric vectors of length 4 todeb_tetraprovides an alternate way to create adeb_tetra vector thandeb_tetra(). This method may be helpful because the data is inputby the value instead of by the unit.

Value

Adeb_tetra vector.

See Also

deb_as_lsd() anddeb_as_decimal()

Examples

# To cast from deb_lsd to deb_tetra an "f" unit must be supplied# Comparelsd1 <- 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_tetrad2 <- deb_decimal(x)deb_as_tetra(d2, f = 4)# Cast a numeric vector to deb_tetradeb_as_tetra(x)# Use the bases argument to apply non-default basesdeb_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))

Equality and comparison

Description

Equality and comparison

Usage

## S3 method for class 'deb_lsd'vec_proxy_equal(x, ...)## S3 method for class 'deb_lsd'vec_proxy_compare(x, ...)## S3 method for class 'deb_tetra'vec_proxy_equal(x, ...)## S3 method for class 'deb_tetra'vec_proxy_compare(x, ...)

Arguments

x

A deb_lsd vector.

...

Arguments passed on to further methods.

Value

A data frame or numeric vector to be used for comparison.


Convert bases ofdeb_lsd,deb_tetra, anddeb_decimal vectors

Description

Convert bases ofdeb_lsd,deb_tetra, anddeb_decimal vectors

Usage

deb_convert_bases(x, to)## Default S3 method:deb_convert_bases(x, to)## S3 method for class 'deb_lsd'deb_convert_bases(x, to)## S3 method for class 'deb_decimal'deb_convert_bases(x, to)## S3 method for class 'deb_tetra'deb_convert_bases(x, to)

Arguments

x

A vector of classdeb_lsd,deb_tetra, ordeb_decimal.

to

Numeric vector of length 2 or 3, representing the bases for thesolidus, denarius, and optionally farthing units to be converted to.

Details

deb_convert_bases() is the only way to change the bases of the solidus,denarius, and farthing units associated with vectors of classdeb_lsd,deb_tetra, anddeb_decimal. It also provides a means to convertbetween tripartite and tetrapartite bases withdeb_decimal vectors.

Ifx is adeb_decimal vector with tetrapartite bases and unit"f"andto is a numeric vector of length 2, the unit will be convertedto"d".

Value

A vector of the same class asx with convertedbases attribute.

Examples

lsd <- deb_lsd(5, 3, 8)dec <- deb_decimal(8.825)dec_tetra <- deb_decimal(1.840625, bases = c(20, 12, 4))tetra <- deb_tetra(1, 16, 9, 3)deb_convert_bases(lsd, to = c(60, 16))deb_convert_bases(dec, to = c(60, 16))deb_convert_bases(dec_tetra, c(60, 16, 8))deb_convert_bases(tetra, to = c(60, 16, 8))# Convert between tripartite and tetrapartite basesdeb_convert_bases(dec, to = c(60, 16, 8))deb_convert_bases(dec_tetra, to = c(20, 12))

Accounts from the practice journal and ledger of Richard Dafforne

Description

A data set of the accounts from the first practice journal and ledger inRichard Dafforne's accounting manual from 1660 calledThe Merchant'sMirrour. By 1660The Merchant's Mirrour was in its third edition, andits contents had been printed in the well-known merchant manual of GerardMalynes,Consuetudo Vel Lex Mercatoira since the 1636 edition, making itone of the most popular bookkeeping manuals in 17th-century England. Thedata set is meant to be used in conjunction withdafforne_transactions.It contains information on the accounts found in the practice journal andledger that Dafforne used to teach double-entry bookkeeping practices.

Usage

dafforne_accounts

Format

A data frame with 46 rows and 5 variables.

Details

The data set does not include the Balance account that Dafforne uses toclose the books. The transactions from this account can be recreated usingthe lsd account functions indebkeepr.

Variables

Source

Richard Dafforne,The Merchant's Mirrour, Or Directions for thePerfect Ordering and Keeping of His Accounts, Third Edition, (London,1660)


Transactions from the practice journal and ledger of Richard Dafforne

Description

A data set of the transactions from the first practice journal and ledger inRichard Dafforne's accounting manual from 1660 calledThe Merchant'sMirrour. By 1660The Merchant's Mirrour was in its third edition, andits contents had been printed in the well-known merchant manual of GerardMalynes,Consuetudo Vel Lex Mercatoira since the 1636 edition, making itone of the most popular bookkeeping manuals in 17th-century England. Thedata set is meant to be used in conjunction withdafforne_accounts. Itcontains the transactions in the practice journal and ledger that Dafforneused to teach double-entry bookkeeping practices.

Usage

dafforne_transactions

Format

A data frame with 177 rows and 8 variables.

Details

The data set does not include the last 16 transactions recorded in thejournal, which deal with the balancing of the book. These transactions canbe recreated using the lsd account functions indebkeepr.

Variables

Source

Richard Dafforne,The Merchant's Mirrour, Or Directions for thePerfect Ordering and Keeping of His Accounts, Third Edition, (London,1660)


Convert the unit ofdeb_decimal vectors

Description

Convert theunit attribute ofdeb_decimal vectors.

Usage

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

Arguments

x

A vector of classdeb_decimal.

to

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

Details

deb_convert_unit() converts theunit of adeb_decimal vector toeither"l","s","d", or optionally"f" if the vector hastetrapartite bases. This changes the representation of the vector,but the value remains equivalent.

Value

Adeb_decimal vector with a convertedunit attribute.

Examples

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")

A decimalized class for tripartite and tetrapartite values

Description

Create a vector of classdeb_decimal to integrate non-decimal currenciesand other measurements that use tripartite or tetrapartite units intostandardized forms of analysis provided by R.

Usage

deb_decimal(x = double(), unit = c("l", "s", "d", "f"), bases = c(20, 12))

Arguments

x

A numeric vector representing the decimalized values of eithertripartite or tetrapartite values.

unit

A character vector of length one indicating the unit for thedecimalized values, either"l" (libra, the default),"s"(solidus),"d" (denarius), or"f" (farthing)."f" is onlyvalid if thebases argument is a numeric vector of length 3 (atetrapartite value).

bases

Numeric vector of length 2 or 3 used to specify the bases forthe solidus or s, denarius or d, and optionally the farthing or f units.Default isc(20, 12), which conforms to the most widely used tripartitesystem of 1 pound = 20 shillings and 1 shilling = 12 pence.

Details

Thedeb_decimal class and thedebkeepr package use the nomenclature ofl, s, and d to represent the tripartitesystem of pounds, shillings, and pence units. The abbreviations derive fromthe Latin termslibra,solidus, anddenarius. In the 8th century asolidus came to represent 12denarii coins, and, for a time at least,240denarii were made from onelibra or pound of silver. The custom ofcounting coins in dozens (solidi) and scores of dozens (librae) spreadthroughout the Carolingian Empire and became ingrained in much of Europe.However, a variety of accounting systems arose at different times that usedother bases for thesolidus anddenarius units and even additional units. Thedeb_decimalclass decimalizes either tripartite or tetrapartite values. Thebasesattribute makes it possible to specify the bases for thesolidus,denarius, and optionally farthing units. Theunit attribute identifiesthe decimalized unit: eitherlibra,solidus,denarius, or farthing.

deb_decimal vectors can either be tripartite, likedeb_lsd, ortetrapartite, likedeb_tetra. These two kinds ofdeb_decimal vectorsare distinguished by the length ofbases attribute (2 for tripartite and3 for tetrapartite) and the addition of the farthing unit for tetrapartite.If thesolidus anddenarius bases are equal, tripartite and tetrapartitedeb_decimal vectors can be combined. The result is adeb_decimal vectorwith tripartite bases.

Value

Returns a vector of classdeb_decimal.

See Also

Thedeb_decimal class works in concert with thedeb_lsd anddeb_tetraclasses. These classes maintain the tripartite (deb_lsd) and tetrapartite(deb_tetra) unit structure of non-decimal currencies and values.Seedeb_lsd() anddeb_tetra().

Examples

# deb_decimal with tripartite unitsdeb_decimal(c(5.25, 3.825, 8.5))# Set the unit of the deb_decimal vectordeb_decimal(c(105, 76.5, 170), unit = "s")deb_decimal(c(1260, 918, 240), unit = "d")# Set the bases of the deb_decimal vectordeb_decimal(c(5.25, 3.825, 8.5), bases = c(60, 16))# Create a prototype or vector of length 0deb_decimal()# To create a tetrapartite value, provide numeric vector# of length 3 to bases argumentdeb_decimal(c(5.11875, 3.234375, 8.2875),            bases = c(20, 12, 4))deb_decimal(c(4914, 3105, 7956),            unit = "f",            bases = c(20, 12, 4))

Test if an object is of classdeb_decimal

Description

Test if an object is of classdeb_decimal.

Usage

deb_is_decimal(x)

Arguments

x

An object.

Value

TRUE if object is of classdeb_decimal andFALSE if it is not.

Examples

x <- deb_decimal(c(5.25, 3.825, 8.5))y <- c(5.25, 3.825, 8.5)deb_is_decimal(x)deb_is_decimal(y)

Test if an object is of classdeb_lsd

Description

Test if an object is of classdeb_lsd.

Usage

deb_is_lsd(x)

Arguments

x

An object.

Value

TRUE if object is of classdeb_lsd andFALSE if it is not.

Examples

x <- deb_lsd(5, 3, 8)y <- c(5, 3, 8)deb_is_lsd(x)deb_is_lsd(y)

Test if an object is of classdeb_tetra

Description

Test if an object is of classdeb_tetra.

Usage

deb_is_tetra(x)

Arguments

x

An object.

Value

TRUE if object is of classdeb_tetra andFALSE if it is not.

Examples

x <- deb_tetra(5, 3, 8, 2)y <- c(5, 3, 8, 2)deb_is_tetra(x)deb_is_tetra(y)

A class for pounds, shillings and pence values

Description

Create a vector of classdeb_lsd to integrate non-decimal currenciesinto standardized forms of analysis provided by R.

Usage

deb_lsd(l = double(), s = double(), d = double(), bases = c(20, 12))

Arguments

l

Numeric vector representing the pounds unit.

s

Numeric vector representing the shillings unit.

d

Numeric vector representing the pence unit.

bases

Numeric vector of length 2 used to specify the bases for thesolidus or s and denarius or d units. Default isc(20, 12), whichconforms to the most widely used system of 1 pound = 20 shillings and1 shilling = 12 pence.

Details

Thedeb_decimal class and thedebkeepr package use the nomenclature ofl, s, and d to represent the tripartitesystem of pounds, shillings, and pence units. The abbreviations derive fromthe Latin termslibra,solidus, anddenarius. In the 8th century asolidus came to represent 12denarii coins, and, for a time at least,240denarii were made from onelibra or pound of silver. The custom ofcounting coins in dozens (solidi) and scores of dozens (librae) spreadthroughout the Carolingian Empire and became ingrained in much of Europe.However, a variety of accounting systems arose at different times that usedother bases for thesolidus anddenarius units. Thebases attribute ofdeb_decimalvectors makes it possible to specify alternative bases for thesolidus anddenarius units.

The length ofl,s, andd must either be all equal, or a vector oflength 1 can be recycled to the length of the other argument(s). Seethevctrs packagefor further details on recycling vectors. In addition,l,s, anddmust either all have no values, resulting in a vector of length 0, or allpossess numeric vectors.

Value

Returns a vector of classdeb_lsd.

See Also

Thedeb_lsd class works in concert with thedeb_decimal class, whichrepresents non-decimal currencies as decimalized values. Seedeb_decimal(). To represent values with tetrapartite units seedeb_tetra().

Examples

deb_lsd(5, 3, 8)deb_lsd(l = c(10, 8, 5),        s = c(6, 13, 8),        d = c(8, 4, 10))# Recycle length 1 vectordeb_lsd(l = c(10, 8, 5),        s = c(6, 13, 8),        d = 0)# Set the bases of the deb_lsd vectordeb_lsd(5, 3, 8, bases = c(60, 16))deb_lsd(l = c(10, 28, 5),        s = c(6, 33, 13),        d = c(8, 42, 10),        bases = c(60, 16))# Create a prototype or vector of length 0deb_lsd()

A class for tetrapartite values

Description

Create a vector of classdeb_tetra to integrate values with four unitsinto standardized forms of analysis provided by R.

Usage

deb_tetra(  l = double(),  s = double(),  d = double(),  f = double(),  bases = c(20, 12, 4))

Arguments

l

Numeric vector representing the pounds unit.

s

Numeric vector representing the shillings unit.

d

Numeric vector representing the pence unit.

f

Numeric vector representing the farthing or fourth unit.

bases

Numeric vector of length 3 used to specify the bases for thesolidus or s, denarius or d, and farthing or f units. Default isc(20, 12, 4), which conforms to the English system of 1 pound =20 shillings, 1 shilling = 12 pence, and 1 pence = 4 farthing.

Details

Thedeb_tetra class extends the concept of thedeb_lsd class toincorporate currencies and other types of values that consist of four units.A variety of currencies and measurements of weights expanded beyond theconventional tripartite system of pounds, shillings, and pence to include afourth unit.deb_tetra adds a fourth unit, namedf for farthing, to thel, s, and d units used bydeb_lsd.Thebases attribute ofdeb_tetra vectors makes it possible to specifyalternative bases for thesolidus,denarius, and farthing units.

The length ofl,s,d, andf must either be all equal, or a vector oflength 1 can be recycled to the length of the other argument(s). Seethevctrs packagefor further details on recycling vectors. In addition,l,s,d, andfmust either all have no values, resulting in a vector of length 0, or allpossess numeric vectors.

Value

Returns a vector of classdeb_tetra.

See Also

Thedeb_tetra class works in concert with thedeb_decimal class,which can represent tetrapartite values as decimalized values. Seedeb_decimal(). To represent values with tripartite units seedeb_lsd().

Examples

deb_tetra(5, 3, 8, 2)deb_tetra(l = c(10, 8, 5),          s = c(6, 13, 8),          d = c(8, 4, 10),          f = c(2, 3, 1))# Recycle length 1 vectordeb_tetra(l = c(10, 8, 5),          s = c(6, 13, 8),          d = c(8, 4, 10),          f = 2)# Set the bases of the deb_tetra vectordeb_tetra(5, 3, 8, 2, bases = c(60, 16, 8))deb_tetra(l = c(10, 28, 5),          s = c(6, 33, 13),          d = c(8, 12, 10),          f = c(5, 3, 6),          bases = c(60, 16, 8))# Create a prototype or vector of length 0deb_tetra()

Castdeb_lsd ordeb_tetra to a list of values

Description

Cast adeb_lsd ordeb_tetra vector to a list of numeric vectors eitherthree or four values per list item corresponding to lsd or tetra values.

Usage

deb_as_list(x, ...)## Default S3 method:deb_as_list(x, ...)## S3 method for class 'deb_lsd'deb_as_list(x, ...)## S3 method for class 'deb_tetra'deb_as_list(x, ...)

Arguments

x

Adeb_lsd ordeb_tetra vector to cast to a list of values.

...

Arguments passed on to further methods.

Details

deb_as_list() turns adeb_lsd ordeb_tetra vector into a list ofnumeric vectors of length 3 or 4. It is the inverse ofdeb_as_lsd() anddeb_as_tetra(). Compare toas.list(), which creates a list ofdeb_lsdordeb_tetra vectors orunclass(), which creates a list of length 3 or4 with numeric vectors corresponding to the units.

Value

A list of numeric vectors of length 3 or 4, corresponding to lsdor tetra values.

See Also

deb_as_lsd() anddeb_as_tetra() for the inverse ofdeb_as_list().

Examples

# deb_lsd vectorx <- deb_lsd(l = 0:3, s = 4:7, d = 8:11)deb_as_list(x)# deb_tetra vectory <- deb_tetra(l = 0:3, s = 4:7, d = 8:11, f = 1:4)deb_as_list(y)# This is the inverse of `deb_as_lsd()` of a list of lsd valuesz <- deb_as_list(x)identical(x, deb_as_lsd(z))

Helpers to create and separate adeb_lsd column in a data frame

Description

Usage

deb_gather_lsd(  df,  l = l,  s = s,  d = d,  bases = c(20, 12),  lsd_col = lsd,  replace = FALSE)deb_spread_lsd(df, lsd = lsd, l_col = l, s_col = s, d_col = d, replace = FALSE)

Arguments

df

A data frame.

l

Pounds column: Unquoted name of a numeric variable correspondingto the pounds or libra unit. Default isl.

s

Shillings column: Unquoted name of a numeric variablecorresponding to the shillings or solidus unit. Default iss.

d

Pence column: Unquoted name of a numeric variable corresponding tothe pence or denarius unit. Default isd.

bases

Numeric vector of length 2 used to specify the bases for thesolidus or s and denarius or d units. Default isc(20, 12), whichconforms to the most widely used system of 1 pound = 20 shillings and1 shilling = 12 pence.

lsd_col

Unquoted name of thedeb_lsd column created by thefunction. Default islsd.

replace

Logical (defaultFALSE). WhenTRUE, the newly createdcolumn(s) will replace the one(s) used to create it/them.

lsd

deb_lsd column: Unquoted name of adeb_lsd column.Default islsd.

l_col

Unquoted name for the pounds column created by the function.Default isl.

s_col

Unquoted name for the shillings column created by the function.Default iss.

d_col

Unquoted name for the pence column created by the function.Default isd.

Details

When transcribing historical accounting data by hand, entering the pounds,shillings, and pence values (lsd) into separate columns is probably theeasiest and least error prone method. Thedeb_gather_() anddeb_spread_() set of functions provide helpers to go back and forthbetween this mode of data entry and the use ofdeb_lsd anddeb_tetravectors within data frames in R.deb_gather_lsd() creates adeb_lsdcolumn froml,s, andd columns representing the three units ofthis type of value.deb_spread_lsd() does the opposite. It takes adeb_lsd column and spreads it into three separate pounds, shillings,and pence columns.

Values for column names (lsd_col,l_col,s_col, andd_col) mustbe valid column names. They can be quoted or unquoted, but they cannot bevectors or bare numbers. This follows the rules ofdplyr::rename().

Value

A data frame with a newdeb_lsd column fordeb_gather_lsd()or new pounds, shillings, and pence columns fordeb_spread_lsd().

See Also

deb_gather_tetra() anddeb_spread_tetra() provide thesame functionality for the less common tetrapartite values of pounds,shillings, pence, and farthings.

Examples

libra <- c(3, 5, 6, 2)solidus <- c(10, 18, 11, 16)denarius <- c(9, 11, 10, 5)# data frame with separate l, s, and d variables and default namesx <- data.frame(accounts = c(1, 2, 3, 4),                l = libra,                s = solidus,                d = denarius)# data frame with deb_lsd variable and default namesy <- data.frame(accounts = c(1, 2, 3, 4),                lsd = deb_lsd(l = libra,                              s = solidus,                              d = denarius))# Gather l, s, and d variables into deb_lsd columndeb_gather_lsd(x, l = l, s = s, d = d)# Spread deb_lsd column into separate l, s, and d columnsdeb_spread_lsd(y, lsd = lsd)# Replace original columns with replace = TRUEdeb_gather_lsd(x, replace = TRUE)deb_spread_lsd(y, replace = TRUE)# Choose non-default column namesdeb_gather_lsd(x, lsd_col = data, replace = TRUE)deb_spread_lsd(y,               l_col = libra,               s_col = solidus,               d_col = denarius,               replace = TRUE)# The two functions are oppositesz <- x %>%  deb_gather_lsd(replace = TRUE) %>%  deb_spread_lsd(replace = TRUE)all.equal(x, z)

Math group withdeb_lsd anddeb_tetra vectors

Description

Math and Summary group of functions withdeb_lsd anddeb_tetra vectors.Implemented functions:

All other functions from the groups not currently implemented,includingmedian(),quantile(), andsummary().

Arguments

x

An vector of classdeb_lsd ordeb_tetra.

...

deb_lsd ordeb_tetra vectors insum() and argumentspassed on to further methods inmean().

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.

Details

sum() andcumsum() return a normalizeddeb_lsd ordeb_tetra values.

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

If you need a wider implementation of Math and Summary group functions,use adeb_decimal vector. However,median(),quantile(), andsummary() are also not currently implemented fordeb_decimal vectors.To use these functions castdeb_lsd,deb_tetra, anddeb_decimalvectors to numeric.

Value

Adeb_lsd ordeb_tetra vector with normalized values.

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 cumsumsum(x)sum(y)cumsum(x)cumsum(y)mean(x)mean(y)# Round family on deb_lsd affects the denarius unitx2 <- deb_lsd(5, 12, 5.8365)y2 <- deb_tetra(5, 12, 8, 4.125)round(x2)round(y2)round(x2, digits = 2)signif(x2, digits = 2)ceiling(x2)ceiling(y2)floor(x2)floor(y2)trunc(x2)trunc(y2)# The returned values are normalized whether# they are positive or negativex3 <- deb_lsd(9, 19, 11.825)x4 <- deb_lsd(-9, -19, -11.825)round(x3)round(x3, digits = 1)ceiling(x3)floor(x4)trunc(x3)trunc(x4)

Methods

Description

Methods


Normalize tripartite and tetrapartite values

Description

Normalize tripartite and tetrapartite values values to given bases.

Usage

deb_normalize(x, ...)## Default S3 method:deb_normalize(x, ...)## S3 method for class 'deb_lsd'deb_normalize(x, ...)## S3 method for class 'numeric'deb_normalize(x, bases = c(20, 12), ...)## S3 method for class 'deb_tetra'deb_normalize(x, ...)

Arguments

x

Either an vector of classdeb_lsd,deb_tetra, or a numericvector of length 3 or 4 representing the values to be normalized.

...

Arguments passed on to further methods.

bases

Used only ifx is a numeric vector. A Numeric vector oflength 2 or 3 used to specify the bases for the solidus or s, denarius ord, and optionally the farthing or f units. Default isc(20, 12), whichconforms to the most widely used system of 1 pound = 20 shillings and 1shilling = 12 pence.

Value

Returns a vector of classdeb_lsd with normalized solidus anddenarius units or a vector of classdeb_tetra with normalized solidus,denarius, and farthing units.

Examples

# Normalize a deb_lsd vectorx <- deb_lsd(12, 93, 78)x_alt <- deb_lsd(12, 93, 78, bases = c(60, 16))deb_normalize(x)deb_normalize(x_alt)# Normalize a deb_tetra vectort <- deb_tetra(12, 83, 78, 42)t_alt <- deb_tetra(12, 83, 78, 42, bases = c(60, 16, 8))deb_normalize(t)deb_normalize(t_alt)# Normalize a numeric vector of length 3deb_normalize(c(12, 93, 78))deb_normalize(c(12, 93, 78), bases = c(60, 16))# Normalize a numeric vector of length 4# Must provide bases of length 3deb_normalize(c(12, 93, 78, 42), bases = c(20, 12, 4))deb_normalize(c(12, 93, 78, 42), bases = c(60, 16, 8))

Helpers to create and separate adeb_tetra column in a data frame

Description

Usage

deb_gather_tetra(  df,  l = l,  s = s,  d = d,  f = f,  bases = c(20, 12, 4),  tetra_col = tetra,  replace = FALSE)deb_spread_tetra(  df,  tetra = tetra,  l_col = l,  s_col = s,  d_col = d,  f_col = f,  replace = FALSE)

Arguments

df

A data frame.

l

Pounds column: Unquoted name of a numeric variable correspondingto the pounds or libra unit. Default isl.

s

Shillings column: Unquoted name of numeric variable correspondingto the shillings or solidus unit. Default iss.

d

Pence column: Unquoted name of numeric variable corresponding tothe pence or denarius unit. Default isd.

f

Farthing column: Unquoted name of numeric variable correspondingto the farthing or f unit. Default isf.

bases

Numeric vector of length 3 used to specify the bases for thesolidus or s, denarius or d, and farthing or f units. Default isc(20, 12, 4), which conforms to the English system of 1 pound =20 shillings, 1 shilling = 12 pence, and 1 pence = 4 farthing.

tetra_col

Unquoted name of thedeb_tetra column created by thefunction. Default istetra.

replace

Logical (defaultFALSE). WhenTRUE, the newly createdcolumn(s) will replace the one(s) used to create it/them.

tetra

deb_tetra column: Unquoted name of adeb_tetra column.Default istetra.

l_col

An unquoted name for the pounds column created by thefunction. Default isl.

s_col

An unquoted name for the shillings column created by thefunction. Default iss.

d_col

An unquoted name for the pence column created by thefunction. Default isd.

f_col

An unquoted name for the farthings column created by thefunction. Default isf.

Details

When transcribing historical accounting data by hand, entering the pounds,shillings, pence, and optionally farthing values (lsd(f)) into separatecolumns is probably the easiest and least error prone method. Thedeb_gather_() anddeb_spread_() set of functions provide helpers togo back and forth between this mode of data entry and the use ofdeb_lsdanddeb_tetra vectors within data frames in R.deb_gather_tetra()creates adeb_tetra column from four separate columns representing thefour units in this type of value.deb_spread_tetra() does the opposite.It takes adeb_tetra column and spreads it into four separate columnsrepresenting the four units.

Values for column names (tetra_col,l_col,s_col,d_col, andf_col) must be valid column names. They can be quoted or unquoted, butthey cannot be vectors or bare numbers. This follows the rules ofdplyr::rename().

Value

A data frame with a newdeb_tetra column fordeb_gather_tetra()or new pounds, shillings, pence, and farthing columns fordeb_spread_tetra().

See Also

deb_gather_lsd() anddeb_spread_lsd() provide the samefunctionality for the more common tripartite values of pounds, shillings,and pence.

Examples

libra <- c(3, 5, 6, 2)solidus <- c(10, 18, 11, 16)denarius <- c(9, 11, 10, 5)farthing <- c(2, 3, 1, 0)# data frame with separate l, s, and d variables and default namesx <- data.frame(accounts = c(1, 2, 3, 4),                l = libra,                s = solidus,                d = denarius,                f = farthing)# data frame with deb_tetra variable and default namesy <- data.frame(accounts = c(1, 2, 3, 4),                tetra = deb_tetra(l = libra,                                  s = solidus,                                  d = denarius,                                  f = farthing))# Gather l, s, d, and f variables into a deb_tetra columndeb_gather_tetra(x, l = l, s = s, d = d, f = f)# Spread deb_tetra column into separate l, s, d, and f columnsdeb_spread_tetra(y, tetra = tetra)# Replace original columns with replace = TRUEdeb_gather_tetra(x, replace = TRUE)deb_spread_tetra(y, replace = TRUE)# Choose non-default column namesdeb_gather_tetra(x, tetra_col = data, replace = TRUE)deb_spread_tetra(y,                 l_col = libra,                 s_col = solidus,                 d_col = denarius,                 f_col = farthing,                 replace = TRUE)# The two functions are oppositesz <- x %>%  deb_gather_tetra(replace = TRUE) %>%  deb_spread_tetra(replace = TRUE)all.equal(x, z)

Formatdeb_lsd,deb_decimal, anddeb_tetra vectors as text

Description

Flexible way to formatdeb_lsd,deb_decimal, anddeb_tetra vectorsfor use as labels or text.

Usage

deb_text(x, ...)## Default S3 method:deb_text(x, ...)## S3 method for class 'deb_lsd'deb_text(  x,  digits = 0,  currency = "£",  l.mark = "",  s.mark = "s.",  d.mark = "d.",  sep = " ",  big.mark = ",",  decimal.mark = ".",  suffix = "",  ...)## S3 method for class 'deb_decimal'deb_text(  x,  digits = 0,  currency = "£",  big.mark = ",",  decimal.mark = ".",  suffix = "",  ...)## S3 method for class 'deb_tetra'deb_text(  x,  digits = 0,  currency = "£",  l.mark = "",  s.mark = "s.",  d.mark = "d.",  f.mark = "f.",  sep = " ",  big.mark = ",",  decimal.mark = ".",  suffix = "",  ...)

Arguments

x

A vector of classdeb_lsd,deb_decimal, ordeb_tetra.

...

Arguments passed on to further methods.

digits

Desired number of digits after the decimal mark to which toround the numeric values. Default is0.

currency

Character used for the currency mark. Default is pound sign.

l.mark

Character used following the pounds (l) unit.Default is"".

s.mark

Character used following the shillings (s) unit.Default is"s.".

d.mark

Character used following the pence (d) unit.Default is"d.".

sep

Character to separate pounds, shillings, pence, and optionallyfarthing units. Default is" ".

big.mark

Character used to mark intervals to the left of the decimalmark. Default is"," with defaultbig.interval of3.

decimal.mark

Character used for decimal mark. Default is".".

suffix

Character placed after the values. Default is"".

f.mark

Character used following the farthing (f) unit withtetrapartite values. Default is"f.".

Details

deb_text is similar toas.character() in that both return a charactervector of the values ofdeb_lsd,deb_decimal, anddeb_tetra vectors.However,as.character() uses the normal printing method for these vectors.deb_text() provides a convenient way to nicely formatdeb_lsd,deb_decimal, anddeb_tetra vectors for use as text or labels withoptions for customization.

deb_text() usesformatC() to format the numeric values ofx. Numbersare printed in non-scientific format and trailing zeros are dropped.

All character vector arguments should be length 1.

Value

A Character vector of formatted values.

See Also

formatC() for further options passed to....

Examples

lsd <- deb_lsd(l = c(10000, 0, -10000),               s = c(8, 0, -8),               d = c(5.8252, 0, -5.8252))dec <- deb_decimal(c(10000.8252, 0, -10000.8252))tetra <- deb_tetra(l = c(10000, 0, -10000),                   s = c(8, 0, -8),                   d = c(5, 0, -5),                   f = c(2.8252, 0, -2.8252))deb_text(lsd)deb_text(dec)deb_text(tetra)# Compact format for deb_lsd with suffix to distinguish currencydeb_text(lsd, s.mark = "", d.mark = "",         sep = ".", suffix = " Flemish")# Control the number of digitsdeb_text(lsd, digits = 3)deb_text(dec, digits = 3)deb_text(tetra, digits = 3)# Change big mark and decimal markdeb_text(lsd, digits = 4, big.mark = ".", decimal.mark = ",")deb_text(dec, digits = 4, big.mark = ".", decimal.mark = ",")deb_text(tetra, digits = 4, big.mark = ".", decimal.mark = ",")

Tidy eval helpers

Description

Tidy eval helpers


Analysis of double-entry bookkeeping

Description

Family of seven related functions to analyze transactions data framesthat have credit, debit, and tetrapartite (lsd) or tetrapartite (lsdf)columns, mimicking an account book.

Usage

deb_account(  df,  account_id,  credit = credit,  debit = debit,  lsd = lsd,  na.rm = FALSE)deb_account_summary(  df,  credit = credit,  debit = debit,  lsd = lsd,  na.rm = FALSE)deb_credit(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)deb_debit(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)deb_current(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)deb_open(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)deb_balance(df, credit = credit, debit = debit, lsd = lsd, na.rm = FALSE)

Arguments

df

A data frame or tibble with at least credit, debit, and lsdcolumns.

account_id

The id of the account to be used to calculate thecredit, debit, and current values.

credit

Credit column: Unquoted name of the credit column,representing the accounts that discharge the transactional values orfrom which the values derive. Default iscredit.

debit

Debit column: Unquoted name of the debit column,representing the accounts that receive the transactional values.Default isdebit.

lsd

Value column: Unquoted name of a column of classdeb_lsd,deb_decimal, ordeb_tetra. Default islsd.

na.rm

Logical. Should missing values (includingNaN) be removed?

Value

Transaction functions return a data frame or tibble with columns for theaccounts indf and credit, debit, and/or current values in the same typeandbases aslsd:

Transactions data frames:

Transactions data frames have the structure of an account book. Theyshould have a similar arrangement todafforne_transactions. Each row isa transaction in the book.credit anddebit columns contain theaccount ids associated with discharging account (credit) and the receivingaccount (debit). Thelsd column represents the tripartite ortetrapartite value of each transaction. Likedafforne_transactions,transactions data frames can have additional columns with attributes foreach transaction such as id or date among others.

Examples

# Examples use dafforne_transactions data,# which have default column names.# See dafforne_accounts for account names.# Credit, debit, and current value of cash accountdeb_account(dafforne_transactions, account_id = 1,            credit = credit, debit = debit,            lsd = lsd)# Credit, debit, and current value of profit and loss accountdeb_account(dafforne_transactions, account_id = 23)# Summary of all accounts in Dafforne's ledgerdeb_account_summary(dafforne_transactions)# Credit of accounts in Dafforne's ledgerdeb_credit(dafforne_transactions)# Debit of accounts in Dafforne's ledgerdeb_debit(dafforne_transactions)# Current value of accounts in Dafforne's ledgercurrent <- deb_current(dafforne_transactions)current# Current value of open account in Dafforne's ledgeropen <- deb_open(dafforne_transactions)open# Compare the amount of rows in returned values of# deb_current() vs deb_open()nrow(current)nrow(open)# Credit and debit remaining on Dafforne's ledgerdeb_balance(dafforne_transactions)

Error message for unimplemented mathematics functions

Description

Error message for unimplemented mathematics functions

Usage

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

Arguments

.fn

A mathematical function from the base package.

.x

A vector.

...

Additional arguments passed to.fn.

Value

Adeb_lsd vector.


Error message for unimplemented mathematics functions

Description

Error message for unimplemented mathematics functions

Usage

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

Arguments

.fn

A mathematical function from the base package.

.x

A vector.

...

Additional arguments passed to.fn.

Value

Adeb_tetra vector.


[8]ページ先頭

©2009-2025 Movatter.jp