prune_coa: Prune plaintext "Chart of Accounts" names to a given maximum...

Description Usage Arguments Examples

View source: R/prune_coa.r

Description

prune_coa is a convenience function that modifies a data frame by either editing in place or making a new variable containing the plaintext "Chart of Accounts" pruned to a given maximum depth e.g. "Assets:Checking:Credit-Union:Account1" at a maximum depth of 2 will be converted to "Assets:Checking". prune_coa uses tidyverse non-standard evaluation (NSE). prune_coa_string is a convenience function which does the pruning operation on character vectors.

Usage

1
2
3
prune_coa(df, depth = 1, variable, name)

prune_coa_string(x, depth = 1)

Arguments

df

A data frame

depth

How deep should the account structure be.

variable

Which variable to make less deep (default is to use "account")

name

New variable name (default is to edit the variable argument in place)

x

Character vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
df <- tibble::tribble(~account, ~amount,
                     "Assets:Checking:BankA", 1000,
                     "Assets:Checking:BankB", 1000,
                     "Assets:Savings:BankA", 1000,
                     "Assets:Savings:BankC", 1000)
prune_coa(df)
prune_coa(df, 2)
prune_coa(df, 3)
prune_coa(df, 4)
prune_coa(df, 2, account, account2)
prune_coa(prune_coa(df, 2, account, account2), 3, account2, account3)
prune_coa_string(df$account, 2)

trevorld/ledger documentation built on Nov. 20, 2021, 3:03 p.m.