Skip to contents

Account books contain various sorts of historically significant data, but the use of non-decimal monetary systems complicates computational analysis of the early development of accounting practices such as double-entry bookkeeping. How should the three separate monetary units be recorded in a data base, and how can they be brought together in ways that facilitate the analysis of account books? So long as these issues exist, the time consuming task of transcribing the transactions in account books into a spreadsheet or data base hardly seems a valuable use of time, thereby precluding the use of digital tools to analyze or visualize the contents.

The debkeepr package seeks to facilitate digital analysis of account books through the implementation of the deb_lsd, deb_tetra, and deb_decimal types that integrate non-decimal values into R.1 At a very practical level, the goal of debkeepr is to make the transcription of historical account books into a data base a more valuable research activity. Once the contents of a set of account books are transcribed into a data base — such as the example journal and ledger from Richard Dafforne’s The Merchant’s Mirrour, Or Directions for the Perfect Ordering and Keeping of His Accounts (London, 1660) used here — debkeepr assists the researcher in both the analysis and presentation of the data. By creating an environment to analyze the contents of account books in R, debkeepr also seeks to make the analysis of accounts more transparent and amendable to the practices of reproducible research.

This vignette uses the practice journal and ledger from the 1660 edition of Richard Dafforne’s Merchant’s Mirrour to show some of the ways that debkeepr facilitates the examination and visualization of a set of account books. An introduction to Richard Dafforne and his manual on double-entry bookkeeping, along with analysis of individual transactions in the journal, can be found in the Transactions in Richard Dafforne’s Journal vignette. The practice journal and ledger in Merchant’s Mirrour provide a good starting point because they are printed — and therefore more accessible — and have a reasonable length. A PDF copy of the journal is available for download.

The data

Dafforne’s example journal and ledger record the mercantile activities of a fictional merchant in London over a seven month period in 1634.2 Following the practices of double-entry bookkeeping, the journal documents each transaction and clearly lists one account as creditor and one as debtor. The accompanying ledger derives entirely from the journal and does not add any new information. Whereas the journal is organized by transaction, the ledger is organized by account. Each transaction is placed in the ledger twice, once under the credit account and once under the debit account — hence double-entry bookkeeping. Dafforne’s journal contains 191 transactions between 47 accounts, and thus the ledger possesses 382 entries divided among the 47 accounts.

The data from these account books are included in the debkeepr package. dafforne_transactions is a data frame that includes all of the transactions from the journal except those dealing with the balance account used to close the books. These transactions are excluded because they can be recreated with the help of debkeepr, as shown in more detail below.3 dafforne_transactions has 177 transactions or rows and 8 variables. Each transaction has a creditor and debtor account, the date of the transaction, and the value in pounds sterling contained in a deb_lsd column. Extra details include the pages on which the transaction can be found in Dafforne’s journal and ledger and a short description of the transaction. Addition information about the accounts that make up the books are contained in the dafforne_accounts data frame. The account id matches those used in the credit and debit variables in dafforne_transactions. This second data frame also has a name for each account and a short description of the account. The investor column presents an extra organizing variable, listing the investor or the person’s whose capital is involved in the account.4

Overview of the account books

At a basic level, placing the contents of a set of account books into a data base can expedite the exploration of the transactions and relationships between the accounts. Even a modestly sized account book such as Dafforne’s journal has too many accounts and transactions to easily keep in one’s mind. To get a sense of the data, it helps to create a visual overview of the transactions and a summary of the accounts. This vignette uses dplyr to manipulate the data and to prepare it for plotting with ggplot2.

# load packages
library(debkeepr)
library(dplyr)
library(ggplot2)

# load data
transactions <- dafforne_transactions
accounts <- dafforne_accounts

Note that deb_lsd vectors cannot currently be plotted with ggplot(). However, the ability to cast deb_lsd() to deb_decimal() makes this limitation relatively easy to overcome. This casting can be done at any point in the data analysis pipeline. The following code simplifies the dafforne_transactions data frame and adds a deb_decimal column.

(transactions <- transactions %>% 
   mutate(dec = deb_as_decimal(lsd)) %>% 
   select(id, credit, debit, date, lsd, dec))
#> # A tibble: 177 × 6
#>       id credit debit date                  lsd          dec
#>    <dbl>  <dbl> <dbl> <date>     <lsd[20s:12d]> <l[20s:12d]>
#>  1     1      2     1 1633-01-01    1000:15s:7d  1000.779167
#>  2     2      2     3 1633-01-01     477:10s:0d   477.500000
#>  3     3      2     4 1633-01-01       55:0s:6d    55.025000
#>  4     4      2     5 1633-01-01      240:0s:0d   240.000000
#>  5     5      2     6 1633-01-01      229:0s:0d   229.000000
#>  6     6      2     8 1633-01-01       3:17s:8d     3.883333
#>  7     7      7     2 1633-01-01      150:0s:0d   150.000000
#>  8     8      9    11 1633-01-04      360:0s:0d   360.000000
#>  9     9      1     9 1633-01-04      144:0s:0d   144.000000
#> 10    10      5    10 1633-01-04      120:0s:0d   120.000000
#> # ℹ 167 more rows

To get a visual overview of the transactions, the value of each transaction can be plotted. Because each transaction is associated with two accounts — a debtor account and a creditor account — the journal could be visualized from the perspective of either the debtor or creditor accounts.

ggplot(data = transactions) + 
  geom_point(aes(x = credit, y = dec), alpha = 0.7) + 
  scale_y_continuous(labels = scales::label_dollar(prefix = "\u00a3")) + 
  labs(x = "Creditor accounts",
       y = "Transaction values",
       title = "Value of Transactions by Creditor Account") + 
  theme_light()

Alternatively, both the credit and debit account can be shown, essentially reproducing a double-entry-bookkeeping ledger, as each transaction is shown twice.

ggplot(data = transactions) + 
  geom_point(aes(x = credit, y = dec, color = "Credit"), alpha = 0.7) + 
  geom_point(aes(x = debit, y = dec, color = "Debit"), alpha = 0.7) + 
  scale_color_manual(values = c(Credit = "black", Debit = "red")) + 
  scale_y_continuous(labels = scales::label_dollar(prefix = "\u00a3")) + 
  labs(x = "Accounts",
       y = "Transaction values",
       color = "Relationship",
       title = "Value of Transactions by Accounts") + 
  theme_light()

The exact values of the transactions are not necessarily easy to follow in these plots with 177 and 354 points respectively, but they give a good sense of the basic distribution of transactions. Only a handful of transactions involved values over £1,000 sterling, and the majority of transactions were for less that £200. The smaller number of transactions over £1,000 make it possible to match up the credit and debit accounts in the plot with both sets of accounts.

The above plots provide a view of the raw data from Dafforne’s journal, but they do little to show an overview of the accounts. What was the total credit or value sent by each account, what was the total debit or value received by each account, and how much value, if any, remained on the account at the closing of the book? These questions can be answered separately with deb_credit(), deb_debit(), and deb_current() or together with deb_account_summary().

# Summary of accounts
deb_account_summary(transactions)
#> # A tibble: 46 × 4
#>    account_id         credit          debit        current
#>         <dbl> <lsd[20s:12d]> <lsd[20s:12d]> <lsd[20s:12d]>
#>  1          1   1956:10s:11d    2903:13s:0d   -947:-2s:-1d
#>  2          2     2006:3s:9d      150:0s:0d     1856:3s:9d
#>  3          3      570:0s:0d      570:0s:0d        0:0s:0d
#>  4          4       75:0s:8d       75:0s:8d        0:0s:0d
#>  5          5      813:3s:0d      813:3s:0d        0:0s:0d
#>  6          6     568:1s:11d      869:2s:7d    -301:0s:-8d
#>  7          7   2958:18s:10d   2958:18s:10d        0:0s:0d
#>  8          8    1580:10s:0d    1580:10s:0d        0:0s:0d
#>  9          9     1744:1s:4d     1744:1s:4d        0:0s:0d
#> 10         10      606:2s:6d      606:2s:6d        0:0s:0d
#> # ℹ 36 more rows

From this information, a line-range plot can be constructed with the upper limit represented by the total credit, the lower limit the total debit, and the current value by a point. Though conceptually it is not always helpful to think of debits as negative values — debits represent the values received by an account — it makes sense in this instance to distinguish credit values from debit values by making debits negative.

# Plot summary of accounts
deb_account_summary(transactions, lsd = dec) %>% 
  mutate(debit = -debit) %>% 
  ggplot() + 
      geom_linerange(aes(x = account_id, ymin = debit, ymax = credit)) + 
      geom_point(aes(x = account_id, y = current,
                     color = if_else(current == 0, "Closed", "Open"))) +
      scale_color_manual(values = c(Open = "black", Closed = "blue")) + 
      scale_y_continuous(labels = scales::label_dollar(prefix = "\u00a3")) + 
      labs(x = "Accounts",
           y = "Pounds sterling",
           color = "Status",
           title = "Summary of the accounts") + 
    theme_light()

This summary plot shows the accounts through which the largest amounts of capital passed and highlights the accounts that remain open at the end of the books compared to those that were closed by having their balance zeroed out.5 The plot provides a good basis to identify and further investigate the most valuable accounts. For instance, we can find the accounts that had a total credit exceeding £1,900 with the help of deb_credit().

deb_credit(transactions) %>%
  filter(lsd > 1900) %>%
  left_join(select(accounts, id, account), by = c("account_id" = "id")) %>% 
  arrange(desc(lsd))
#> # A tibble: 6 × 3
#>   account_id            lsd account                                         
#>        <dbl> <lsd[20s:12d]> <chr>                                           
#> 1         13     3430:7s:9d James Wilkinson                                 
#> 2          7   2958:18s:10d Jacob Symonson - account current                
#> 3         18     2447:3s:5d Randoll Rice - account current                  
#> 4         38    2215:13s:9d Amsterdam exchange - company with Jacob Symonson
#> 5          2     2006:3s:9d Stock                                           
#> 6          1   1956:10s:11d Cash

Relationship between accounts

The above plots treat either the transactions or accounts as discrete entities. However, an account book is naturally relational. The structure of dafforne_transactions and dafforne_accounts purposely mimics that used to create network graphs. dafforne_transactions has the form of a directed edge list: each transaction is a link between two accounts with the values going from the credit account to the debit account. dafforne_accounts is a node list or a data frame in which each account id found in either the credit or debit column of dafforne_transactions is listed along with additional information about the accounts. There are a variety of ways to create and plot network graphs in R, but this vignette uses igraph to create the graph object and ggraph to plot the graph.

A network graph can show various types of information beyond the linking of the accounts by associating the edges or links and the nodes or accounts with variables from the data. The links between the accounts can be related to the total value of the transactions in each direction, and the nodes can be associated with either the total value they received (debit) or sent (credit). Extra information can be added to the nodes by joining the total values for each account with columns from the dafforne_accounts data. In this case, the “investor” variable is attached to the debit values for each account. ggraph currently works best with regular numeric vectors, and so the deb_lsd column is transformed into numeric for both nodes and edges and these columns are labeled as val.

library(igraph)
library(ggraph)

# Nodes: Total debit for each account
debits <- deb_debit(transactions, lsd = lsd) %>% 
  mutate(val = as.numeric(lsd)) %>% 
  left_join(select(accounts, id, investor), by = c("account_id" = "id"))

# Edges: Sum of transactions by link
transactions_sum <- transactions %>% 
  group_by(credit, debit) %>% 
  summarise(lsd = sum(lsd), .groups = "drop") %>% 
  mutate(val = as.numeric(lsd)) %>% 
  arrange(val)

# Create igraph object
ledger_graph <- graph_from_data_frame(d = transactions_sum,
                                      vertices = debits,
                                      directed = TRUE)

The creation of an igraph object opens a whole set of tools for analyzing the account books, but here the network analysis is primarily restricted to its visualization. The following graph shows the total value of the transactions between each set of accounts using the transparency of the link, and arrows are present on the edges to show the direction of the transaction from the creditor account to the debtor account. The size of the node is used to represent the total accumulated value for each account. The nodes are labeled with their account id and colored by the “investor” variable.

# Ledger graph
set.seed(240)
ggraph(ledger_graph, layout = "kk") + 
  geom_edge_fan(aes(alpha = val),
                width = 1,
                arrow = arrow(length = unit(2, 'mm'),
                              type = "closed"),
                end_cap = circle(3, 'mm')) + 
  scale_edge_alpha(labels = scales::dollar_format(prefix = "£")) + 
  geom_node_point(aes(size = val, color = investor), alpha = 0.9) + 
  scale_color_brewer(palette = "Paired", direction = -1) + 
  geom_node_text(aes(label = name)) + 
  scale_size_continuous(range = c(1, 10),
                        labels = scales::dollar_format(prefix = "£")) + 
  labs(color = "Investor",
       size = "Accumulated Value",
       edge_alpha = "Accumulated \n Transactions",
       title = "Network of Dafforne's Journal") + 
  theme_graph()
#> Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
#>  Please use `linewidth` in the `default_aes` field and elsewhere instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

The graph helps to identify the accounts that had the largest amount of capital pass through them, and the level of transparency of the edges shows the movement of capital. The transparency of the edges makes clear the significant movement of capital among communities of accounts such as the triad of accounts 7, 8, and 13 deriving from the sale of cochineal — an insect used to make a red dye — for Jacob Symonson to James Wilkinson.6 The Kamada-Kawai layout algorithm places the nodes with the highest centrality, or the most connections, towards the center. Those that have fewer connections are placed on the outside. It is unsurprising to see the central position of accounts such as account 1, the cash account, since any payment or reception of cash went through this account. This arrangement of the nodes can be confirmed by showing the accounts that have the most connections or links to other accounts.

# 10 accounts with the most connections
sort(degree(ledger_graph), decreasing = TRUE)[1:10]
Connections per account
1 23 9 13 7 18 37 38 10 16
24 18 15 15 14 12 11 9 8 8

The use of the “investor” variable for the color of the nodes is one of a variety of ways in which the accounts could be grouped. The graph helps to demonstrate the meaningfulness of the grouping, as well as highlighting something about Dafforne’s bookkeeping practices. This can be seen through a comparison of the involvement of four different merchants in the account book: Jacob Symonson, Randoll Rice, George Pinchback, and Diego del Varino. Both Jacob Symonson and Randoll Rice invested in a number of companies with the bookkeeper, but the accounts that involved the capital of Symonson (pink) interacted with more of the bookkeeper’s accounts (light orange) and a greater variety of accounts that involved other merchants than did those of Randoll Rice. Whereas the Kamada-Kawai algorithm places Symonson’s account close to the bookkeeper’s most significant accounts, Rice’s many accounts (light blue) mostly interacted with each other and so are shown towards the top of the graph, away from the center.

Compare the placement of the accounts of Rice to the single account for the merchant George Pinchback (red). Pinchback was involved in both the purchase and sale of goods, and this one account has 15 links to and from other accounts, making it quite central to the network.7 On the other end of the spectrum are the three accounts containing Diego del Varino’s capital (orange). Del Varino served as a factor in Lisbon for ventures made by the company that the bookkeeper had with Randoll Rice (accounts 30 and 36), but the orange accounts (40, 41, and 42) represent the bookkeeper’s work as Del Varino’s factor. These accounts have transactions between each other but with relatively few other accounts, leading to their placement on the periphery of the graph. The comparison of the visual representation of the accounts of these four merchants is further demonstrated by creating a table relating the total links and accounts per the investor grouping.

# Total links per investor
total_links <- tibble(id = as.numeric(names(degree(ledger_graph))),
                      links = degree(ledger_graph)) %>% 
  left_join(select(accounts, id, investor), by = "id") %>% 
  group_by(investor) %>% 
  summarise(links = sum(links), .groups = "drop") %>% 
  arrange(desc(links))

# Accounts per investor
accounts_investor <- accounts %>% 
  group_by(investor) %>% 
  summarise(accounts = n(), .groups = "drop")

# Create table
left_join(total_links, accounts_investor, by = "investor") %>% 
  knitr::kable(caption = "Links and accounts per investor")
Links and accounts per investor
investor links accounts
Ego 72 8
Jacob Symonson 71 12
Randoll Rice 60 13
George Pinchback 15 1
James Wilkinson 15 1
Andrew Hitchcock 11 1
Diego del Varino 11 3
Jean du Boys 10 2
Arthur Mumperson 9 2
Linden, Does, Reinst 8 3

Moving beyond the comparison of accounts bearing the capital of merchants, the visual structure of the graph and the grouping by investor demonstrates a more general bookkeeping practice recommended by Dafforne, namely the division of types of capital or ventures into separate accounts. This practice is seen most clearly in the multiple accounts involving Jacob Symonson and Randoll Rice, but the simplest example may be the three accounts of Diego del Varino. Instead of encompassing the work the bookkeeper performed as Del Varino’s factor within a single account, the bookkeeper spread the capital among three separate accounts. Accounts 40, 41, and 42 record the sale of fruit for Del Varino to Randoll Rice (account 40), Rice’s partial payment in cash resulting in the creation of an account of ready money for Del Varino (account 41), and a separate current account for the remainder of the sale (account 42).

The practice of creating multiple accounts facilitated the calculation of profits or losses associated with individual ventures, but it also means that the total transactional value of an account book is a less meaningful measurement of capital investment than it might first appear. To properly keep track of various types of capital, Dafforne often transferred capital from one account to another, leading the same or similar values to be recorded multiple times. Thus, the total debit and sum of the transactions relating to the sale of fruit for Del Varino in his three accounts of £1446 18s. was much greater than the proceeds of the sale of £541 4s. 9d.

(varino_debits <- filter(debits, account_id %in% 40:42))
#> # A tibble: 3 × 4
#>   account_id            lsd   val investor        
#>        <dbl> <lsd[20s:12d]> <dbl> <chr>           
#> 1         40      541:4s:9d  541. Diego del Varino
#> 2         41     405:10s:7d  406. Diego del Varino
#> 3         42      500:2s:8d  500. Diego del Varino

# Total debit
sum(varino_debits$lsd)
#> <deb_lsd[1]>
#> [1] 1446:18s:0d
#> # Bases: 20s 12d

Analyzing individual accounts

The summary of accounts in Dafforne’s practice journal and ledger and the visualization of their relationships provide a good basis for further analysis into the workings of individual accounts. The accounts chosen for further inquiry and the nature of the analysis will differ according to the account book and the research questions being asked. This example concentrates on the development of the bookkeeper’s capital during the period covered by the journal and ledger by investigating the opening of the books through the stock account (account 2), the calculation of profits and losses during this period (account 23), and the state of the books at the time of their closing.

According to Dafforne, at the opening of a new set of account books the merchant must create an inventory in which all cash, unsold wares, debtors, and creditors are listed in relation to the stock account. Of this account Dafforne explains that it

“containeth in it, all what a man possesseth; whether Money, Wares, Debts due to us, or the like: and (marke this well) Cash, yea, each particular thing that I possesse, is but a member of that whole body stocke; therefore by the joynt meeting of all those members, the body (Stock) is made compleat.”8

We can get a better understanding of the inventory or opening of the books by inspecting the stock account. One way to do this is to recreate the ledger entries for the account. The dafforne_transactions data is presented in the form of the journal: each transaction is listed once and tied to two accounts. The ledger can be replicated by finding all debit transactions for an account — the left side of the page in the ledger — and all credit transactions for the account — the right side of the ledger.

# Stock is debtor
filter(transactions, debit == 2)
#> # A tibble: 1 × 6
#>      id credit debit date                  lsd          dec
#>   <dbl>  <dbl> <dbl> <date>     <lsd[20s:12d]> <l[20s:12d]>
#> 1     7      7     2 1633-01-01      150:0s:0d          150

# Stock is creditor
filter(transactions, credit == 2)
#> # A tibble: 6 × 6
#>      id credit debit date                  lsd          dec
#>   <dbl>  <dbl> <dbl> <date>     <lsd[20s:12d]> <l[20s:12d]>
#> 1     1      2     1 1633-01-01    1000:15s:7d  1000.779167
#> 2     2      2     3 1633-01-01     477:10s:0d   477.500000
#> 3     3      2     4 1633-01-01       55:0s:6d    55.025000
#> 4     4      2     5 1633-01-01      240:0s:0d   240.000000
#> 5     5      2     6 1633-01-01      229:0s:0d   229.000000
#> 6     6      2     8 1633-01-01       3:17s:8d     3.883333

The ledger also includes the sum of the debits and credits, which can be presented using the deb_account() function.

# Summary of stock account
deb_account(transactions, account_id = 2)
#> # A tibble: 3 × 2
#>   relation            lsd
#>   <chr>    <lsd[20s:12d]>
#> 1 credit       2006:3s:9d
#> 2 debit         150:0s:0d
#> 3 current      1856:3s:9d

The inventory consisted of seven items: six credits or items that served to increase the bookkeeper’s stock and one debit of money he owed to another. When taken together, the inventory demonstrated that the bookkeeper’s credits exceeded his liabilities by £1,856 3s. 9d., which represents the sum of the bookkeeper’s estate on 1 January 1633 English style. This means that over 92% of the capital in the inventory belonged to the bookkeeper.

# Percentage of bookkeeper's stock to total capital
deb_lsd(1856, 3, 9) / deb_lsd(2006, 3, 9)
#> [1] 0.9252313

The most significant account for the development of the bookkeeper’s capital or stock over the course of the journal and ledger was that of profit and loss (account 23). Completed ventures or accounts were balanced by bringing the difference between the total credit and debit to the profit and loss account. Ventures that result in more credit than debit — for instance if the sale of goods (credit) was more than the purchase of the goods plus any expenses (debit) — create a profit. In such as case profit and loss is made creditor to the account for the difference. The opposite occurs with losses. Thus, a merchant hopes to have more credit than debit in the account of profit and loss, which is what occurred in Dafforne’s practice books.

# Summary of profit and loss
deb_account(transactions, account_id = 23)
#> # A tibble: 3 × 2
#>   relation            lsd
#>   <chr>    <lsd[20s:12d]>
#> 1 credit      1075:8s:11d
#> 2 debit          29:0s:1d
#> 3 current     1046:8s:10d

The account books only showed three small losses or debits during the course of the books, so it is more interesting to concentrate on the much more substantial profits. A useful measurement is to see not only the raw value that each account created in profits but also the relation of that value to the total profits, shown here as a percentage.

# Percentage of profits by account
transactions %>% 
  filter(credit == 23) %>% 
  group_by(debit) %>% 
  summarise(lsd = sum(lsd), .groups = "drop") %>% 
  mutate(pct = lsd / deb_lsd(1046, 8, 10) * 100) %>% 
  left_join(accounts, by = c("debit" = "id")) %>% 
  select(id = debit, account, lsd, pct) %>%
  arrange(desc(pct))
#> # A tibble: 16 × 4
#>       id account                                                     lsd    pct
#>    <dbl> <chr>                                            <lsd[20s:12d]>  <dbl>
#>  1    21 Profit and loss - company with Randoll Rice          298:18s:4d 28.6  
#>  2    12 Kerseys in company with Jacob Symonson                128:5s:0d 12.3  
#>  3    29 Figs - company with Randoll Rice                     114:15s:5d 11.0  
#>  4    11 Voyage to Amsterdam - Jacob Symonson                 111:17s:0d 10.7  
#>  5     3 Wares                                                 92:10s:0d  8.84 
#>  6    24 Voyage to Lisbon - company with Jacob Symonson        63:17s:9d  6.11 
#>  7     5 Jean du Boys - account current                         56:5s:6d  5.38 
#>  8     6 Jacob Symonson - account by him in company             50:0s:0d  4.78 
#>  9     9 George Pinchback                                       36:5s:0d  3.46 
#> 10     8 Jacob Symonson - Cochineal                            31:12s:2d  3.02 
#> 11    38 Amsterdam exchange - company with Jacob Symonson       22:0s:8d  2.11 
#> 12     4 Kettles                                                20:0s:2d  1.91 
#> 13    16 Interest reckoning                                     16:6s:2d  1.56 
#> 14     1 Cash                                                   13:4s:0d  1.26 
#> 15    26 Danzig exchange - company with Arthur Mumperson       10:19s:9d  1.05 
#> 16    27 Jacob Symonson - Cambric cloth                         8:12s:0d  0.822

Closing the books

The process of closing a set of books as described by Dafforne involved identifying open accounts — those that still had a positive or negative balance — and transferring the remaining balance to an account Dafforne called “Balance.”9 This account and the transactions that serve to balance the accounts in the books are absent from dafforne_transactions and dafforne_accounts, but they can be recreated here. The first step is to identify all accounts that remained open on July 20th, 1634 when Dafforne closed the books.

# Open accounts: Arranged from credits to debits
(balance <- deb_open(transactions) %>% 
  left_join(select(accounts, id, account), by = c("account_id" = "id")) %>% 
  arrange(desc(lsd)))
#> # A tibble: 14 × 3
#>    account_id             lsd account                                           
#>         <dbl>  <lsd[20s:12d]> <chr>                                             
#>  1          2      1856:3s:9d Stock                                             
#>  2         23     1046:8s:10d Profit and loss                                   
#>  3         19       991:7s:6d Randoll Rice - account by me in company           
#>  4         14       512:3s:8d Jacob Symonson - account by me in company         
#>  5         33        99:7s:7d Hendrick vander Linden, John van Does, Jaques Rei…
#>  6         46       93:19s:8d Hendrick vander Linden, John van Does, Jaques Rei…
#>  7         35    -189:-12s:0d Voyage to Antwerp - company with Randoll Rice     
#>  8          6     -301:0s:-8d Jacob Symonson - account by him in company        
#>  9         39   -402:-12s:-1d Arthur Mumperson                                  
#> 10         43    -413:-6s:-8d Thomas Trust - company with Randoll Rice - accoun…
#> 11         37   -446:-12s:-9d Andrew Hitchcock                                  
#> 12         45   -806:-6s:-11d Figs - company with Jacob Symonson                
#> 13          1    -947:-2s:-1d Cash                                              
#> 14         20 -1092:-17s:-10d Jean du Boys - company with Randoll Rice

This operation essentially recreates the the Balance account as used by Dafforne, though one alteration must be made before they are truly equivalent. According to Dafforne, the penultimate step in creating a balance is to close the account for profits and loss by “carrying the difference to your Stock account.”10 Adding the value remaining in the profit and loss account (account 23) to the stock account (account 2) calculates the total capital held by the bookkeeper, while also balancing the profit and loss account so that it can again calculate the profits and losses experienced during the duration of the next set of books. Thus, a true balance as described by Dafforne would show that the stock account concluded with a total credit of £2,902 12s. 7d.

# Stock at the close of the books
stock_balance <- filter(balance, account_id == 2 | account_id == 23)

sum(stock_balance$lsd)
#> <deb_lsd[1]>
#> [1] 2902:12s:7d
#> # Bases: 20s 12d

This information enabled merchants to understand the development of their capital. In this instance, the bookkeeper’s capital grew by over 56% in less than eight months, as his capital or stock — the amount that the credits on his book surpassed the debits — increased from £1,856 3s. 9d. to £2,902 12s. 7d.

# Percentage of growth: profits over opening capital
balance$lsd[[2]] / balance$lsd[[1]]
#> [1] 0.5637586

Not only did the bookkeeper’s own capital grow rapidly, but the capital contained in the account books increased even more quickly. Whereas there had only been a total of £2,006 3s. 9d. in the books at the time of the inventory, by the closing of the books, the assets and liabilities remaining on the books had more than doubled to £4,599 11s., a growth of 129%. This of course meant that bookkeeper’s stock, or the amount that his assets exceeded his liabilities, now constituted a much smaller percentage of the capital as a whole, having decreased from the original 92% to a much more reasonable 63%. This ratio of the bookkeeper’s estate to total capital in his account books indicates a more mature and diversified trading portfolio than is present at the time of the inventory.

# Total balance remaining on the books
deb_balance(transactions)
#> # A tibble: 2 × 2
#>   relation            lsd
#>   <chr>    <lsd[20s:12d]>
#> 1 credit      4599:11s:0d
#> 2 debit     -4599:-11s:0d

# Growth in the capital on the books
(deb_lsd(4599, 11, 0) - deb_lsd(2006, 3, 9)) / deb_lsd(2006, 3, 9)
#> [1] 1.292682

# Percentage of bookkeeper's stock to total capital
sum(balance$lsd[1:2]) / deb_lsd(4599, 11, 0)
#> [1] 0.6310681

Conclusion

The analysis of Dafforne’s practice journal and ledger presented here provides a glimpse into the types of investigations, calculations, and visualizations that debleepr makes possible. Most of the calculations and even the visuals presented in this vignette could be made without debkeepr. Of course, in the seventeenth century merchants had to make all of their accounting calculations by hand. Yet, this was and is a cumbersome activity. It is not a particularly mathematically difficult task to add together the credits or debits of the accounts remaining open at the closing of the book, but it is certainly easier to use deb_balance(transactions). The task is more difficult when the question is the total transactional value that passed through the account book. Here, sum(transactions$lsd) is much preferable to manually adding every single value in the book. Moreover, while it is possible to reproduce the plots showing the values of the transactions or the summary of the accounts, this would involve long periods of data entry that might not be of much use beyond the single implementation.

At the same time, debkeepr introduces tools of analysis that are not possible without the ability to manipulate pounds, shillings, and pence within a data base. The network graph of the transactions in Dafforne’s journal would be difficult to recreate without debkeepr, especially if you wanted to maintain total accuracy and be able to see the values in pounds, shillings, and pence form. The transformation of data from an account book into a network graph opens up all kinds of new forms of analysis. This vignette has only scratched the surface of the possibilities.

The most valuable tool that debkeepr brings to the analysis of historical economic data that takes the form of pounds, shillings, and pence values is the possibility of quickly iterating over problems and providing solutions that are reproducible. debkeepr enables a workflow for entering data from account books into a data base, tidying the data by transforming separate pounds, shillings, and pence variables into deb_lsd or deb_decimal columns, and then exploring, analyzing, and visualizing the data in ways that integrate with the tidyverse and more general practices of data analysis in R. Take for instance the last set of calculations concerning the balance to close the books and its relation to the bookkeeper’s stock. The calculations could be done by hand, but the steps become more transparent when done through code. Another example of this is the calculation of percentage of profits by account for the profit and loss account. Each step in the analysis can be followed and individually critiqued to ensure that the calculations are properly made. In addition, the process is easily replicated for all other accounts in the account book. In other words, debkeepr provides a powerful and transparent set of tools for the investigation and analysis of the social interactions found in historical account books.