| Title: | Personal Finance Calculations for the Field Manual |
|---|---|
| Description: | Small, tested functions for the calculations in the personal finance field manual: budgeting, savings, emergency funds, debt payoff, loans and mortgages, investing, retirement accounts, insurance, and federal income taxes. |
| Authors: | Martin Frigaard [aut, cre] |
| Maintainer: | Martin Frigaard <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9001 |
| Built: | 2026-12-04 20:13:10 UTC |
| Source: | https://github.com/mjfrigaard/perfinr |
Taxes the contribution once at tax_rate (today for a Roth, in
retirement for a traditional account) and grows it at rate. From the
Retirement accounts chapter.
after_tax_value(contribution, tax_rate, rate, years)after_tax_value(contribution, tax_rate, rate, years)
contribution |
Amount contributed. |
tax_rate |
Tax rate applied, as a decimal. |
rate |
Yearly return, as a decimal. |
years |
Number of years. |
A numeric vector of after tax values.
Other retirement accounts:
employer_match()
# Roth: taxed at today's 12% rate after_tax_value(contribution = 1000, tax_rate = 0.12, rate = 0.07, years = 40) # Traditional: taxed at a 22% rate in retirement after_tax_value(contribution = 1000, tax_rate = 0.22, rate = 0.07, years = 40)# Roth: taxed at today's 12% rate after_tax_value(contribution = 1000, tax_rate = 0.12, rate = 0.07, years = 40) # Traditional: taxed at a 22% rate in retirement after_tax_value(contribution = 1000, tax_rate = 0.22, rate = 0.07, years = 40)
Matches each rule's Pattern (a regular expression, case ignored)
against the transaction Description. The first matching rule wins;
unmatched rows get "Other". From the Tracking spending chapter.
apply_rules(df, rules)apply_rules(df, rules)
df |
A data frame of transactions with a character |
rules |
A data frame with character |
df with a Category column added (or replaced).
Other tracking spending:
subscription_opportunity_cost()
transactions <- data.frame( Description = c("SAFEWAY #123", "NETFLIX.COM", "SHELL OIL", "ATM FEE") ) rules <- data.frame( Pattern = c("safeway|trader joe", "netflix|spotify", "shell|chevron"), Category = c("Groceries", "Subscriptions", "Gas") ) apply_rules(transactions, rules)transactions <- data.frame( Description = c("SAFEWAY #123", "NETFLIX.COM", "SHELL OIL", "ATM FEE") ) rules <- data.frame( Pattern = c("safeway|trader joe", "netflix|spotify", "shell|chevron"), Category = c("Groceries", "Subscriptions", "Gas") ) apply_rules(transactions, rules)
The effective yearly rate of an annual percentage rate (APR) compounded
periods_per_year times. From the Managing debt chapter.
apr_to_apy(apr, periods_per_year = 365)apr_to_apy(apr, periods_per_year = 365)
apr |
Annual percentage rate, as a decimal. |
periods_per_year |
Compounding periods per year. Defaults to 365 (daily, as most credit cards compound). Must be greater than 0. |
A numeric vector of APYs, as decimals.
Other managing debt:
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# 24% APR compounded daily apr_to_apy(apr = 0.24)# 24% APR compounded daily apr_to_apy(apr = 0.24)
The extra deductible risk divided by the yearly premium savings. From the Insurance chapter.
break_even_years(high_deductible, low_deductible, yearly_savings)break_even_years(high_deductible, low_deductible, yearly_savings)
high_deductible |
The higher deductible. |
low_deductible |
The lower deductible. |
yearly_savings |
Yearly premium savings from the higher deductible. Must be greater than 0. |
A numeric vector of years (not rounded).
Other insurance:
plan_cost()
# $1,000 vs. $500 deductible, saving $150 a year break_even_years(high_deductible = 1000, low_deductible = 500, yearly_savings = 150)# $1,000 vs. $500 deductible, saving $150 a year break_even_years(high_deductible = 1000, low_deductible = 500, yearly_savings = 150)
Card balance as a percent of the credit limit. From the Managing debt chapter.
credit_utilization(balance, credit_limit)credit_utilization(balance, credit_limit)
balance |
Card balance. |
credit_limit |
Credit limit. Must be greater than 0. |
A numeric vector of percentages.
Other managing debt:
apr_to_apy(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# $900 balance on a $3,000 limit credit_utilization(balance = 900, credit_limit = 3000)# $900 balance on a $3,000 limit credit_utilization(balance = 900, credit_limit = 3000)
Monthly debt payments as a percent of gross monthly income. From the Managing debt chapter.
dti_ratio(monthly_debt_payments, gross_monthly_income)dti_ratio(monthly_debt_payments, gross_monthly_income)
monthly_debt_payments |
Total monthly debt payments. |
gross_monthly_income |
Gross (before tax) monthly income. Must be greater than 0. |
A numeric vector of percentages.
Other managing debt:
apr_to_apy(),
credit_utilization(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# $1,061 in debt payments on $3,750 gross income dti_ratio(monthly_debt_payments = 1061, gross_monthly_income = 3750)# $1,061 in debt payments on $3,750 gross income dti_ratio(monthly_debt_payments = 1061, gross_monthly_income = 3750)
Compounds a balance monthly at annual_rate / 12 for a number of
months. From the Emergency fund chapter.
ef_growth(balance, annual_rate, months)ef_growth(balance, annual_rate, months)
balance |
Starting balance. |
annual_rate |
Annual interest rate, as a decimal. |
months |
Number of months. |
A numeric vector of balances.
Other emergency fund:
emergency_fund_target(),
monthly_contribution_needed(),
months_to_ef_goal()
# $9,600 at a 4% annual rate for 12 months ef_growth(balance = 9600, annual_rate = 0.04, months = 12)# $9,600 at a 4% annual rate for 12 months ef_growth(balance = 9600, annual_rate = 0.04, months = 12)
Monthly essential expenses times the number of months to cover. From the Emergency fund chapter.
emergency_fund_target(monthly_expenses, months = 3)emergency_fund_target(monthly_expenses, months = 3)
monthly_expenses |
Essential expenses per month. |
months |
Months of expenses to cover. Defaults to 3. |
A numeric vector of target balances.
Other emergency fund:
ef_growth(),
monthly_contribution_needed(),
months_to_ef_goal()
# $2,400/month in essential expenses, 3-month and 6-month targets emergency_fund_target(monthly_expenses = 2400, months = 3) emergency_fund_target(monthly_expenses = 2400, months = 6)# $2,400/month in essential expenses, 3-month and 6-month targets emergency_fund_target(monthly_expenses = 2400, months = 3) emergency_fund_target(monthly_expenses = 2400, months = 6)
The employer matches match_rate of contributions up to
match_limit_pct of salary. From the Retirement accounts chapter.
employer_match(salary, contribution_pct, match_limit_pct, match_rate)employer_match(salary, contribution_pct, match_limit_pct, match_rate)
salary |
Yearly salary. |
contribution_pct |
Share of salary you contribute, as a decimal. |
match_limit_pct |
Share of salary the employer will match, as a decimal. |
match_rate |
Employer match per dollar contributed, as a decimal
( |
A numeric vector of yearly match amounts.
Other retirement accounts:
after_tax_value()
# $45,000 salary, 6% contribution, 50% match on the first 6% employer_match(salary = 45000, contribution_pct = 0.06, match_limit_pct = 0.06, match_rate = 0.50) # same job, but only contributing 3% employer_match(salary = 45000, contribution_pct = 0.03, match_limit_pct = 0.06, match_rate = 0.50)# $45,000 salary, 6% contribution, 50% match on the first 6% employer_match(salary = 45000, contribution_pct = 0.06, match_limit_pct = 0.06, match_rate = 0.50) # same job, but only contributing 3% employer_match(salary = 45000, contribution_pct = 0.03, match_limit_pct = 0.06, match_rate = 0.50)
From the Major purchases chapter.
first_payment_split(principal, annual_rate, years)first_payment_split(principal, annual_rate, years)
principal |
Loan amount (a single number). |
annual_rate |
Yearly interest rate, as a decimal (a single number). |
years |
Loan term in years (a single number). |
A one row data frame with columns payment, interest,
principal, and pct_interest (the percent of the payment that is
interest).
Other major purchases:
mortgage_payment(),
rent_buy_threshold()
# first payment on a $480,000 loan at 6% over 30 years first_payment_split(principal = 480000, annual_rate = 0.06, years = 30)# first payment on a $480,000 loan at 6% over 30 years first_payment_split(principal = 480000, annual_rate = 0.06, years = 30)
From the Income chapter.
fixed_cost_ratio(fixed_costs, take_home)fixed_cost_ratio(fixed_costs, take_home)
fixed_costs |
Monthly fixed costs (rent, insurance, loan payments). |
take_home |
Monthly take home pay. Must be greater than 0. |
A numeric vector of percentages.
Other income:
pay_frequency_from_days(),
pay_period_days(),
pay_period_full_time_hours(),
pay_periods_per_year(),
raise_invested_value(),
wealth_formula()
fixed_cost_ratio(fixed_costs = 1800, take_home = 3200)fixed_cost_ratio(fixed_costs = 1800, take_home = 3200)
Compounds present_value once per year. From the Investing basics
chapter.
future_value(present_value, rate, years)future_value(present_value, rate, years)
present_value |
Amount invested today. |
rate |
Yearly return, as a decimal. |
years |
Number of years. |
A numeric vector of future values.
Other investing basics:
future_value_series(),
real_return(),
rule_of_72()
# $10,000 at 7% for 10 years future_value(present_value = 10000, rate = 0.07, years = 10) # same $10,000 across several horizons future_value(present_value = 10000, rate = 0.07, years = c(5, 10, 20, 30))# $10,000 at 7% for 10 years future_value(present_value = 10000, rate = 0.07, years = 10) # same $10,000 across several horizons future_value(present_value = 10000, rate = 0.07, years = c(5, 10, 20, 30))
Subtracts the expense ratio from the yearly return, then compounds monthly contributions. From the Index funds chapter.
future_value_after_fees(contribution, annual_return, expense_ratio, years)future_value_after_fees(contribution, annual_return, expense_ratio, years)
contribution |
Monthly contribution. |
annual_return |
Yearly return before fees, as a decimal. |
expense_ratio |
Yearly expense ratio, as a decimal. |
years |
Number of years. |
A numeric vector of ending balances.
Other index funds:
yearly_fee()
# $300/month for 40 years at 7%, index fund vs. active fund index_fund <- future_value_after_fees(300, 0.07, 0.0004, 40) active_fund <- future_value_after_fees(300, 0.07, 0.01, 40) index_fund - active_fund# $300/month for 40 years at 7%, index fund vs. active fund index_fund <- future_value_after_fees(300, 0.07, 0.0004, 40) active_fund <- future_value_after_fees(300, 0.07, 0.01, 40) index_fund - active_fund
Contributions are made at the end of each period. rate is the rate per
period, so use 0.07 / 12 for monthly contributions at 7% a year. At a 0%
rate this is contribution * periods. From the Investing basics
chapter.
future_value_series(contribution, rate, periods)future_value_series(contribution, rate, periods)
contribution |
Amount contributed each period. |
rate |
Return per period, as a decimal. |
periods |
Number of periods. |
A numeric vector of ending balances.
Other investing basics:
future_value(),
real_return(),
rule_of_72()
# $500/month for 30 years at 7% a year future_value_series(contribution = 500, rate = 0.07 / 12, periods = 30 * 12)# $500/month for 30 years at 7% a year future_value_series(contribution = 500, rate = 0.07 / 12, periods = 30 * 12)
Grows a principal at an annual percentage yield (APY). From the High yield accounts chapter.
hysa_balance(principal, annual_apy, years = 1)hysa_balance(principal, annual_apy, years = 1)
principal |
Starting balance. |
annual_apy |
Annual percentage yield, as a decimal. |
years |
Number of years. Defaults to 1. |
A numeric vector of balances.
# $9,600 at 4% APY after 1 year, then after 5 years hysa_balance(principal = 9600, annual_apy = 0.04, years = 1) hysa_balance(principal = 9600, annual_apy = 0.04, years = 5)# $9,600 at 4% APY after 1 year, then after 5 years hysa_balance(principal = 9600, annual_apy = 0.04, years = 1) hysa_balance(principal = 9600, annual_apy = 0.04, years = 5)
Discretionary income is adjusted gross income (AGI) above
threshold_pct times the poverty guideline. The yearly payment is
payment_rate of that, split into 12 months and rounded to cents. From
the Managing debt chapter.
idr_monthly_payment( agi, poverty_guideline = 15960, threshold_pct = 1.5, payment_rate = 0.1 )idr_monthly_payment( agi, poverty_guideline = 15960, threshold_pct = 1.5, payment_rate = 0.1 )
agi |
Adjusted gross income. |
poverty_guideline |
Federal poverty guideline for the household size. Defaults to 15960 (one person). |
threshold_pct |
Multiple of the poverty guideline that is protected. Defaults to 1.5 (150%). |
payment_rate |
Share of discretionary income paid each year. Defaults to 0.10. |
A numeric vector of monthly payments.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# IBR: $50,000 AGI, 150% threshold, 10% rate idr_monthly_payment(agi = 50000) # IBR for loans before July 2014: 15% rate idr_monthly_payment(agi = 50000, payment_rate = 0.15)# IBR: $50,000 AGI, 150% threshold, 10% rate idr_monthly_payment(agi = 50000) # IBR for loans before July 2014: 15% rate idr_monthly_payment(agi = 50000, payment_rate = 0.15)
Applies the 2026 federal brackets for single filers to income after the standard deduction. From the Taxes chapter.
income_tax(income, deduction = 16100)income_tax(income, deduction = 16100)
income |
Gross yearly income (a single number). |
deduction |
Deduction subtracted before the brackets apply. Defaults to the 2026 standard deduction, 16100. |
A single number: the yearly federal income tax.
Other taxes:
raise_kept()
# 2026 federal income tax on a $45,000 salary tax <- income_tax(income = 45000) tax # effective rate tax / 45000# 2026 federal income tax on a $45,000 salary tax <- income_tax(income = 45000) tax # effective rate tax / 45000
A ratio above 1 means you owe more than a year of starting pay. From the Managing debt chapter.
loan_income_ratio(loan_total, expected_salary)loan_income_ratio(loan_total, expected_salary)
loan_total |
Total student loan balance. |
expected_salary |
Expected yearly starting salary. Must be greater than 0. |
A numeric vector of ratios.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# $45,000 in loans, $42,000 expected starting salary loan_income_ratio(loan_total = 45000, expected_salary = 42000)# $45,000 in loans, $42,000 expected starting salary loan_income_ratio(loan_total = 45000, expected_salary = 42000)
Rounds up to whole dollars and returns 0 when the target is already met. From the Emergency fund chapter.
monthly_contribution_needed(target, current_balance, months)monthly_contribution_needed(target, current_balance, months)
target |
Target balance. |
current_balance |
Amount already saved. |
months |
Months until the deadline. Must be greater than 0. |
A numeric vector of whole dollar monthly contributions.
Other emergency fund:
ef_growth(),
emergency_fund_target(),
months_to_ef_goal()
# $9,600 target, $1,200 saved, want to finish in 18 months monthly_contribution_needed(target = 9600, current_balance = 1200, months = 18)# $9,600 target, $1,200 saved, want to finish in 18 months monthly_contribution_needed(target = 9600, current_balance = 1200, months = 18)
The level monthly deposit that grows to goal in months at
annual_rate, compounded monthly. At a 0% rate this is goal / months.
From the Financial goals chapter.
monthly_for_goal(goal, annual_rate, months)monthly_for_goal(goal, annual_rate, months)
goal |
Target amount. |
annual_rate |
Yearly interest rate, as a decimal. |
months |
Number of monthly deposits. Must be greater than 0. |
A numeric vector of monthly deposits.
Other financial goals:
months_to_fund()
# $15,000 in 5 years at 4%, compared to no interest monthly_for_goal(goal = 15000, annual_rate = 0.04, months = 60) monthly_for_goal(goal = 15000, annual_rate = 0, months = 60)# $15,000 in 5 years at 4%, compared to no interest monthly_for_goal(goal = 15000, annual_rate = 0.04, months = 60) monthly_for_goal(goal = 15000, annual_rate = 0, months = 60)
The "pay yourself first" amount: gross monthly income times the savings rate. From the Automating savings chapter.
monthly_savings(gross_monthly_income, savings_rate)monthly_savings(gross_monthly_income, savings_rate)
gross_monthly_income |
Gross (before tax) monthly income. |
savings_rate |
Share of income to save, as a decimal. |
A numeric vector of monthly savings amounts.
# $4,000 gross monthly income, 20% savings rate monthly_savings(gross_monthly_income = 4000, savings_rate = 0.20)# $4,000 gross monthly income, 20% savings rate monthly_savings(gross_monthly_income = 4000, savings_rate = 0.20)
mortgage_payment() with federal student loan defaults: 6.5% over 10
years. From the Managing debt chapter.
monthly_standard_payment(principal, annual_rate = 0.065, years = 10)monthly_standard_payment(principal, annual_rate = 0.065, years = 10)
principal |
Loan amount. |
annual_rate |
Yearly interest rate, as a decimal. Defaults to 0.065. |
years |
Repayment term in years. Defaults to 10. |
A numeric vector of monthly payments.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# standard 10-year monthly payment on $45,000 monthly_standard_payment(principal = 45000)# standard 10-year monthly payment on $45,000 monthly_standard_payment(principal = 45000)
From the Budgeting chapter.
months_to_break_even(upfront_cost, monthly_savings)months_to_break_even(upfront_cost, monthly_savings)
upfront_cost |
One time cost. |
monthly_savings |
Amount saved each month because of the purchase. Must be greater than 0. |
A numeric vector of months (not rounded).
Other budgeting:
opportunity_cost(),
percent_of_income(),
to_annual(),
to_monthly()
# $600 upfront to save $50 a month months_to_break_even(upfront_cost = 600, monthly_savings = 50)# $600 upfront to save $50 a month months_to_break_even(upfront_cost = 600, monthly_savings = 50)
Rounds up to whole months and returns 0 when the target is already met. From the Emergency fund chapter.
months_to_ef_goal(target, current_balance, monthly_contribution)months_to_ef_goal(target, current_balance, monthly_contribution)
target |
Target balance. |
current_balance |
Amount already saved. |
monthly_contribution |
Amount added each month. Must be greater than 0. |
A numeric vector of whole months.
Other emergency fund:
ef_growth(),
emergency_fund_target(),
monthly_contribution_needed()
# $9,600 target, $1,200 saved, $400/month contribution months_to_ef_goal(target = 9600, current_balance = 1200, monthly_contribution = 400)# $9,600 target, $1,200 saved, $400/month contribution months_to_ef_goal(target = 9600, current_balance = 1200, monthly_contribution = 400)
Rounds up to whole months and ignores interest. From the Financial goals chapter.
months_to_fund(goal, monthly)months_to_fund(goal, monthly)
goal |
Target amount. |
monthly |
Amount set aside each month. Must be greater than 0. |
A numeric vector of whole months.
Other financial goals:
monthly_for_goal()
# one at a time: trip first, then car months_to_fund(3000, 600) months_to_fund(3000 + 9000, 600)# one at a time: trip first, then car months_to_fund(3000, 600) months_to_fund(3000 + 9000, 600)
Interest compounds monthly at apr / 12. The result is not rounded; the
last payment is a partial one. Errors when the payment does not cover the
first month's interest, because the balance would never be paid off.
From the Managing debt chapter.
months_to_payoff(balance, monthly_payment, apr)months_to_payoff(balance, monthly_payment, apr)
balance |
Current balance. Must be greater than 0. |
monthly_payment |
Fixed monthly payment. Must be greater than 0. |
apr |
Annual percentage rate, as a decimal. |
A numeric vector of months.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
order_avalanche(),
order_snowball(),
payoff_vs_invest(),
total_interest()
# $5,000 balance, $100/month, 22% APR months_to_payoff(balance = 5000, monthly_payment = 100, apr = 0.22)# $5,000 balance, $100/month, 22% APR months_to_payoff(balance = 5000, monthly_payment = 100, apr = 0.22)
The standard amortization formula with monthly compounding. At a 0% rate
this is principal / (years * 12). From the Major purchases chapter.
mortgage_payment(principal, annual_rate, years)mortgage_payment(principal, annual_rate, years)
principal |
Loan amount. |
annual_rate |
Yearly interest rate, as a decimal. |
years |
Loan term in years. Must be greater than 0. |
A numeric vector of monthly payments.
Other major purchases:
first_payment_split(),
rent_buy_threshold()
# $480,000 loan at 6% over 30 years mortgage_payment(principal = 480000, annual_rate = 0.06, years = 30)# $480,000 loan at 6% over 30 years mortgage_payment(principal = 480000, annual_rate = 0.06, years = 30)
Total assets minus total debts. From the Estate planning chapter.
net_worth(assets, debts)net_worth(assets, debts)
assets |
Numeric vector of asset values. |
debts |
Numeric vector of debt balances. |
A single number.
Other estate planning:
beneficiary_share()
assets <- c(k401 = 12000, roth_ira = 6000, savings = 8000, car = 9000) debts <- c(car_loan = 6000, credit_card = 1000) net_worth(assets, debts)assets <- c(k401 = 12000, roth_ira = 6000, savings = 8000, car = 9000) debts <- c(car_loan = 6000, credit_card = 1000) net_worth(assets, debts)
The future value of a one time amount if it were invested instead of spent. From the Budgeting chapter.
opportunity_cost(amount, rate, years)opportunity_cost(amount, rate, years)
amount |
Amount spent today. |
rate |
Yearly return, as a decimal. |
years |
Number of years. |
A numeric vector of future values.
Other budgeting:
months_to_break_even(),
percent_of_income(),
to_annual(),
to_monthly()
# $1,000 invested at 7% for 30 years opportunity_cost(amount = 1000, rate = 0.07, years = 30)# $1,000 invested at 7% for 30 years opportunity_cost(amount = 1000, rate = 0.07, years = 30)
Highest APR first. From the Managing debt chapter.
order_avalanche(debts)order_avalanche(debts)
debts |
A data frame with a numeric |
debts, reordered by apr from highest to lowest.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_snowball(),
payoff_vs_invest(),
total_interest()
debts <- data.frame( name = c("Card A", "Card B", "Card C"), balance = c(1000, 5000, 2000), apr = c(0.18, 0.24, 0.15) ) order_avalanche(debts)debts <- data.frame( name = c("Card A", "Card B", "Card C"), balance = c(1000, 5000, 2000), apr = c(0.18, 0.24, 0.15) ) order_avalanche(debts)
Smallest balance first. From the Managing debt chapter.
order_snowball(debts)order_snowball(debts)
debts |
A data frame with a numeric |
debts, reordered by balance from smallest to largest.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
payoff_vs_invest(),
total_interest()
debts <- data.frame( name = c("Card A", "Card B", "Card C"), balance = c(1000, 5000, 2000), apr = c(0.18, 0.24, 0.15) ) order_snowball(debts)debts <- data.frame( name = c("Card A", "Card B", "Card C"), balance = c(1000, 5000, 2000), apr = c(0.18, 0.24, 0.15) ) order_snowball(debts)
The inverse of pay_period_days(). Each frequency has its own day count,
so the match is never ambiguous.
pay_frequency_from_days(days)pay_frequency_from_days(days)
days |
A day count, as |
The frequency, or NA_character_ when days is NA or matches
none.
Other income:
fixed_cost_ratio(),
pay_period_days(),
pay_period_full_time_hours(),
pay_periods_per_year(),
raise_invested_value(),
wealth_formula()
pay_frequency_from_days(14) pay_frequency_from_days(10)pay_frequency_from_days(14) pay_frequency_from_days(10)
The nominal length of a pay period, for display. "semimonthly" (15) and
"monthly" (30) are round numbers, so don't annualize with them; use
pay_periods_per_year() instead.
pay_period_days(frequency)pay_period_days(frequency)
frequency |
One of |
A number of days: 7, 14, 15, or 30.
Other income:
fixed_cost_ratio(),
pay_frequency_from_days(),
pay_period_full_time_hours(),
pay_periods_per_year(),
raise_invested_value(),
wealth_formula()
pay_period_days("biweekly")pay_period_days("biweekly")
Assumes a 40-hour week, so the result depends on the frequency alone.
pay_period_full_time_hours(frequency)pay_period_full_time_hours(frequency)
frequency |
One of |
Hours: 40, 80, about 85.7, or about 171.4.
Other income:
fixed_cost_ratio(),
pay_frequency_from_days(),
pay_period_days(),
pay_periods_per_year(),
raise_invested_value(),
wealth_formula()
pay_period_full_time_hours("biweekly")pay_period_full_time_hours("biweekly")
A biweekly schedule pays 26 times a year, not 24, so two months a year
bring a third paycheck. Use this count, not 365 / pay_period_days(), to
turn one paycheck into a yearly figure.
pay_periods_per_year(frequency)pay_periods_per_year(frequency)
frequency |
One of |
An integer number of pay periods.
Other income:
fixed_cost_ratio(),
pay_frequency_from_days(),
pay_period_days(),
pay_period_full_time_hours(),
raise_invested_value(),
wealth_formula()
pay_periods_per_year("biweekly") 2500 * pay_periods_per_year("biweekly") # a year of $2,500 paycheckspay_periods_per_year("biweekly") 2500 * pay_periods_per_year("biweekly") # a year of $2,500 paychecks
Compares a loan's interest rate to an expected investment return. From the Managing debt chapter.
payoff_vs_invest(loan_rate, expected_return)payoff_vs_invest(loan_rate, expected_return)
loan_rate |
Loan interest rate, as a decimal (a single number). |
expected_return |
Expected yearly return, as a decimal (a single number). |
A single string: "Pay off the debt", "Invest the difference",
or "Roughly a wash; do both".
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
total_interest()
# 5% student loan vs. expected 7% return payoff_vs_invest(loan_rate = 0.05, expected_return = 0.07)# 5% student loan vs. expected 7% return payoff_vs_invest(loan_rate = 0.05, expected_return = 0.07)
From the Budgeting chapter.
percent_of_income(expense, income)percent_of_income(expense, income)
expense |
Expense amount. |
income |
Income for the same period as |
A numeric vector of percentages (30 is 30%).
Other budgeting:
months_to_break_even(),
opportunity_cost(),
to_annual(),
to_monthly()
percent_of_income(expense = 1500, income = 5000)percent_of_income(expense = 1500, income = 5000)
Premiums for the year plus medical costs (capped at the out of pocket maximum), minus any employer HSA contribution. From the Insurance chapter.
plan_cost(monthly_premium, medical_cost, oop_max, employer_hsa = 0)plan_cost(monthly_premium, medical_cost, oop_max, employer_hsa = 0)
monthly_premium |
Monthly premium. |
medical_cost |
Medical costs for the year. Use |
oop_max |
Out of pocket maximum. |
employer_hsa |
Employer HSA contribution. Defaults to 0. |
A numeric vector of yearly costs.
Other insurance:
break_even_years()
# Plan A vs. Plan B in a healthy year ($300 of care) and the worst year plan_cost(100, c(300, Inf), oop_max = 3000) plan_cost(40, c(300, Inf), oop_max = 5000, employer_hsa = 500)# Plan A vs. Plan B in a healthy year ($300 of care) and the worst year plan_cost(100, c(300, Inf), oop_max = 3000) plan_cost(40, c(300, Inf), oop_max = 5000, employer_hsa = 500)
Weights the stock and bond returns by the share of the portfolio held in stocks. From the Asset allocation chapter.
portfolio_return(stock_pct, stock_return, bond_return)portfolio_return(stock_pct, stock_return, bond_return)
stock_pct |
Share of the portfolio in stocks, as a decimal ( |
stock_return |
Stock return for the period, as a decimal. |
bond_return |
Bond return for the period, as a decimal. |
A numeric vector of portfolio returns, as decimals.
Other asset allocation:
rebalance_amount()
# 100/0, 80/20, and 60/40 in an average year and a bad year splits <- c(1, 0.8, 0.6) portfolio_return(splits, stock_return = 0.10, bond_return = 0.04) portfolio_return(splits, stock_return = -0.40, bond_return = 0)# 100/0, 80/20, and 60/40 in an average year and a bad year splits <- c(1, 0.8, 0.6) portfolio_return(splits, stock_return = 0.10, bond_return = 0.04) portfolio_return(splits, stock_return = -0.40, bond_return = 0)
Invests monthly_raise * invest_share every month, compounded monthly.
From the Income chapter.
raise_invested_value(monthly_raise, invest_share, rate, years)raise_invested_value(monthly_raise, invest_share, rate, years)
monthly_raise |
Monthly increase in take home pay. |
invest_share |
Share of the raise invested, as a decimal. |
rate |
Yearly return, as a decimal. |
years |
Number of years. |
A numeric vector of ending balances.
Other income:
fixed_cost_ratio(),
pay_frequency_from_days(),
pay_period_days(),
pay_period_full_time_hours(),
pay_periods_per_year(),
wealth_formula()
# invest half of a $200/month raise at 7% for 30 years raise_invested_value(200, invest_share = 0.5, rate = 0.07, years = 30)# invest half of a $200/month raise at 7% for 30 years raise_invested_value(200, invest_share = 0.5, rate = 0.07, years = 30)
The raise minus the extra tax it causes, using income_tax(). From the
Taxes chapter.
raise_kept(old_income, raise)raise_kept(old_income, raise)
old_income |
Yearly income before the raise (a single number). |
raise |
Yearly raise amount (a single number). |
A single number: the raise after federal income tax.
Other taxes:
income_tax()
# $2,000 raise on a $66,000 salary raise_kept(old_income = 66000, raise = 2000)# $2,000 raise on a $66,000 salary raise_kept(old_income = 66000, raise = 2000)
The exact (Fisher) real return. From the Investing basics chapter.
real_return(nominal, inflation)real_return(nominal, inflation)
nominal |
Nominal yearly return, as a decimal. |
inflation |
Yearly inflation rate, as a decimal. |
A numeric vector of real returns, as decimals.
Other investing basics:
future_value(),
future_value_series(),
rule_of_72()
# 7% nominal return against 3% inflation real_return(nominal = 0.07, inflation = 0.03)# 7% nominal return against 3% inflation real_return(nominal = 0.07, inflation = 0.03)
The difference between the target dollar amount for an asset class and the amount currently held. From the Asset allocation chapter.
rebalance_amount(target_pct, total, current_amount)rebalance_amount(target_pct, total, current_amount)
target_pct |
Target share of the portfolio, as a decimal. |
total |
Total portfolio value. |
current_amount |
Current value held in the asset class. |
A numeric vector. Positive values are amounts to buy; negative values are amounts to sell.
Other asset allocation:
portfolio_return()
# $5,600 in stocks and $2,000 in bonds after a 30% stock drop rebalance_amount(target_pct = 0.80, total = 5600 + 2000, current_amount = 5600)# $5,600 in stocks and $2,000 in bonds after a 30% stock drop rebalance_amount(target_pct = 0.80, total = 5600 + 2000, current_amount = 5600)
The 5% rule: yearly unrecoverable costs of owning (property tax, maintenance, cost of capital) are about 5% of the home value. Rent below this monthly amount favors renting. From the Major purchases chapter.
rent_buy_threshold(home_value, unrecoverable_rate = 0.05)rent_buy_threshold(home_value, unrecoverable_rate = 0.05)
home_value |
Price of the home. |
unrecoverable_rate |
Yearly unrecoverable cost as a share of home value. Defaults to 0.05. |
A numeric vector of monthly rent thresholds.
Other major purchases:
first_payment_split(),
mortgage_payment()
# $500,000 home at the standard 5% rate rent_buy_threshold(home_value = 500000)# $500,000 home at the standard 5% rate rent_buy_threshold(home_value = 500000)
A quick estimate: 72 divided by the yearly return in percent. From the Investing basics chapter.
rule_of_72(annual_return_pct)rule_of_72(annual_return_pct)
annual_return_pct |
Yearly return as a percent ( |
A numeric vector of years.
Other investing basics:
future_value(),
future_value_series(),
real_return()
rule_of_72(annual_return_pct = 7)rule_of_72(annual_return_pct = 7)
Income left after spending, as a percent of income. From the Savings strategies chapter.
savings_rate(income, spending)savings_rate(income, spending)
income |
Income for the period. Must be greater than 0. |
spending |
Spending for the same period. |
A numeric vector of percentages.
# $3,200 take home, $2,720 spent savings_rate(income = 3200, spending = 2720)# $3,200 take home, $2,720 spent savings_rate(income = 3200, spending = 2720)
Invests the yearly cost of a subscription at the end of each year. From the Tracking spending chapter.
subscription_opportunity_cost(monthly_cost, years, rate = 0.07)subscription_opportunity_cost(monthly_cost, years, rate = 0.07)
monthly_cost |
Monthly subscription cost. |
years |
Number of years. |
rate |
Yearly return, as a decimal. Defaults to 0.07. |
A numeric vector of ending balances.
Other tracking spending:
apply_rules()
# a $15/month subscription over 30 years subscription_opportunity_cost(monthly_cost = 15, years = 30)# a $15/month subscription over 30 years subscription_opportunity_cost(monthly_cost = 15, years = 30)
Uses 365 days, 52 weeks, and 12 months per year. From the Budgeting chapter.
to_annual(amount, period = c("daily", "weekly", "monthly"))to_annual(amount, period = c("daily", "weekly", "monthly"))
amount |
Amount per |
period |
One of |
A numeric vector of yearly amounts.
Other budgeting:
months_to_break_even(),
opportunity_cost(),
percent_of_income(),
to_monthly()
to_annual(5, period = "daily") to_annual(1500, period = "monthly")to_annual(5, period = "daily") to_annual(1500, period = "monthly")
Uses 30.44 days and 4.33 weeks per month. From the Budgeting chapter.
to_monthly(amount, period = c("daily", "weekly", "annual"))to_monthly(amount, period = c("daily", "weekly", "annual"))
amount |
Amount per |
period |
One of |
A numeric vector of monthly amounts.
Other budgeting:
months_to_break_even(),
opportunity_cost(),
percent_of_income(),
to_annual()
to_monthly(5, period = "daily") to_monthly(60000, period = "annual")to_monthly(5, period = "daily") to_monthly(60000, period = "annual")
All payments minus the amount borrowed. From the Managing debt chapter.
total_interest(monthly_payment, n_months, principal)total_interest(monthly_payment, n_months, principal)
monthly_payment |
Monthly payment. |
n_months |
Number of payments. |
principal |
Amount borrowed. |
A numeric vector of total interest.
Other managing debt:
apr_to_apy(),
credit_utilization(),
dti_ratio(),
idr_monthly_payment(),
loan_income_ratio(),
monthly_standard_payment(),
months_to_payoff(),
order_avalanche(),
order_snowball(),
payoff_vs_invest()
# 6-year car loan vs. 4-year, $20,000 principal at 7% total_interest(monthly_payment = 340.98, n_months = 72, principal = 20000) total_interest(monthly_payment = 478.92, n_months = 48, principal = 20000)# 6-year car loan vs. 4-year, $20,000 principal at 7% total_interest(monthly_payment = 340.98, n_months = 72, principal = 20000) total_interest(monthly_payment = 478.92, n_months = 48, principal = 20000)
The future value of saving median_income * savings_rate at the end of
each year (contributions plus growth). From the Income chapter.
wealth_formula(median_income, savings_rate, annual_return, years)wealth_formula(median_income, savings_rate, annual_return, years)
median_income |
Yearly income. |
savings_rate |
Share of income saved, as a decimal. |
annual_return |
Yearly return, as a decimal. |
years |
Number of years. |
A numeric vector of ending balances.
Other income:
fixed_cost_ratio(),
pay_frequency_from_days(),
pay_period_days(),
pay_period_full_time_hours(),
pay_periods_per_year(),
raise_invested_value()
# $45,000 income, 20% saved, 7% return, 30 years wealth_formula(45000, savings_rate = 0.20, annual_return = 0.07, years = 30)# $45,000 income, 20% saved, 7% return, 30 years wealth_formula(45000, savings_rate = 0.20, annual_return = 0.07, years = 30)
Balance times the fund's expense ratio. From the Index funds chapter.
yearly_fee(balance, expense_ratio)yearly_fee(balance, expense_ratio)
balance |
Amount invested. |
expense_ratio |
Yearly expense ratio, as a decimal ( |
A numeric vector of yearly fees.
Other index funds:
future_value_after_fees()
# $10,000 in an index fund vs. an active fund yearly_fee(balance = 10000, expense_ratio = c(0.0004, 0.01))# $10,000 in an index fund vs. an active fund yearly_fee(balance = 10000, expense_ratio = c(0.0004, 0.01))