budgetr, as you might have guessed, is an R package that helps you easily create budgets.
This introductory vignette provides a brief description of the functions provided by budgetr along with some simple examples on how to construct your budget. Please refer to the function documentation for more technical information on each of these functions.
budgetr makes it easy to extend your recurring monthly cash flow out over time. To do this, budgetr uses three primary abstractions:
Say that you’re budgeting for 2017 and you have three things that constitute your monthly budget:
Your first step in budgeting is to create the items themselves, which you can do with the create_item
function:
# Create a paycheck item
paycheck <- create_item( name = "Paycheck"
, amount = 1000
, day = "2017-01-01"
, recurring = "monthly"
)
# Create a rent item
rent <- create_item( name = "Rent"
, amount = -500
, day = "2017-01-05"
, recurring = "monthly"
)
# Create an internet item
internet <- create_item( name = "Internet"
, amount = -100
, day = "2017-01-05"
, recurring = "monthly"
)
Next you need to create a schedule out of these items, which you can do with the create_schedule
function:
your_schedule <- create_schedule(paycheck, rent, internet)
Lastly (but not leastly!) you need to create your budget, which you can do with the create_budget
function:
your_budget <- create_budget(your_schedule, start="2017-01-01", initial=1000)
Let’s see what it looks like!
your_budget
## budget (budgetr)
## date name amount balance
## 2017-01-01 Initial Amount 1000 1000
## 2017-01-01 Paycheck 1000 2000
## 2017-01-05 Rent -500 1500
## 2017-01-05 Internet -100 1400
## 2017-02-01 Paycheck 1000 2400
## 2017-02-05 Rent -500 1900
## 2017-02-05 Internet -100 1800
## 2017-03-01 Paycheck 1000 2800
## 2017-03-05 Rent -500 2300
## 2017-03-05 Internet -100 2200
## 2017-04-01 Paycheck 1000 3200
Looks like you’re netting $400 a month, but let’s plot it out to get a visual!
plot(your_budget)
In reality we have a lot more than three items in our budget. Let’s say that we actually have the following things in our budget for the next few months:
First we need to create those items:
# Paycheck items
paycheck1 <- create_item( name = "Paycheck"
, amount = 1000
, day = "2017-01-01"
, recurring = "monthly"
)
paycheck15 <- create_item( name = "Paycheck"
, amount = 1000
, day = "2017-01-15"
, recurring = "monthly"
)
# Grocery items
groceries <- create_item( name = "Groceries"
, amount = -100
, day = "2017-01-01"
, recurring = "weekly"
)
# Rent item
rent <- create_item( name = "Rent"
, amount = -500
, day = "2017-01-05"
, recurring = "monthly"
)
# Internet item
internet <- create_item( name = "Internet"
, amount = -100
, day = "2017-01-15"
, recurring = "monthly"
)
# Student loan item
student_loan <- create_item( name = "Student Loan"
, amount = -100
, day = "2017-01-23"
, recurring = "monthly"
)
# Car item
car <- create_item( name = "Car"
, amount = -200
, day = "2017-01-25"
, recurring = "monthly"
)
It would be a pain to have to type out all of those items, so let’s use get_items
to grab all of the items in our environment to create our schedule!
your_schedule <- create_schedule(get_items())
We then create our budget!
your_budget <- create_budget(your_schedule, start="2017-01-01", initial=2000)
your_budget
## budget (budgetr)
## date name amount balance
## 2017-01-01 Initial Amount 2000 2000
## 2017-01-01 Groceries -100 1900
## 2017-01-01 Paycheck 1000 2900
## 2017-01-05 Rent -500 2400
## 2017-01-08 Groceries -100 2300
## 2017-01-15 Groceries -100 2200
## 2017-01-15 Internet -100 2100
## 2017-01-15 Paycheck 1000 3100
## 2017-01-22 Groceries -100 3000
## 2017-01-23 Student Loan -100 2900
## 2017-01-25 Car -200 2700
## 2017-01-29 Groceries -100 2600
## 2017-02-01 Paycheck 1000 3600
## 2017-02-05 Groceries -100 3500
## 2017-02-05 Rent -500 3000
## 2017-02-12 Groceries -100 2900
## 2017-02-15 Internet -100 2800
## 2017-02-15 Paycheck 1000 3800
## 2017-02-19 Groceries -100 3700
## 2017-02-23 Student Loan -100 3600
## 2017-02-25 Car -200 3400
## 2017-02-26 Groceries -100 3300
## 2017-03-01 Paycheck 1000 4300
## 2017-03-05 Groceries -100 4200
## 2017-03-05 Rent -500 3700
## 2017-03-12 Groceries -100 3600
## 2017-03-15 Internet -100 3500
## 2017-03-15 Paycheck 1000 4500
## 2017-03-19 Groceries -100 4400
## 2017-03-23 Student Loan -100 4300
## 2017-03-25 Car -200 4100
## 2017-03-26 Groceries -100 4000
## 2017-04-01 Paycheck 1000 5000
plot(your_budget)
We’ll need to recreate our budget every so often. There are several ways to do so depending on your personal preference, which include but are not limited to:
save
and saveRDS
to save a workspace with your items or to save your individual items, schedules, and budgetsBut what if our rent goes up? It’s easy to update our rent
item with the update_item
function. Any arguments not specified (e.g. name
) will be remain unchanged.
rent <- update_item(rent, amount=-750)
We can then recreate our schedule (using the get_items()
function to include all items in our current environment) and budget to see if anything substantial changed!
your_schedule <- create_schedule(get_items())
your_budget <- create_budget(your_schedule, start="2017-01-01", initial=2000)
your_budget
## budget (budgetr)
## date name amount balance
## 2017-01-01 Initial Amount 2000 2000
## 2017-01-01 Groceries -100 1900
## 2017-01-01 Paycheck 1000 2900
## 2017-01-05 Rent -750 2150
## 2017-01-08 Groceries -100 2050
## 2017-01-15 Groceries -100 1950
## 2017-01-15 Internet -100 1850
## 2017-01-15 Paycheck 1000 2850
## 2017-01-22 Groceries -100 2750
## 2017-01-23 Student Loan -100 2650
## 2017-01-25 Car -200 2450
## 2017-01-29 Groceries -100 2350
## 2017-02-01 Paycheck 1000 3350
## 2017-02-05 Groceries -100 3250
## 2017-02-05 Rent -750 2500
## 2017-02-12 Groceries -100 2400
## 2017-02-15 Internet -100 2300
## 2017-02-15 Paycheck 1000 3300
## 2017-02-19 Groceries -100 3200
## 2017-02-23 Student Loan -100 3100
## 2017-02-25 Car -200 2900
## 2017-02-26 Groceries -100 2800
## 2017-03-01 Paycheck 1000 3800
## 2017-03-05 Groceries -100 3700
## 2017-03-05 Rent -750 2950
## 2017-03-12 Groceries -100 2850
## 2017-03-15 Internet -100 2750
## 2017-03-15 Paycheck 1000 3750
## 2017-03-19 Groceries -100 3650
## 2017-03-23 Student Loan -100 3550
## 2017-03-25 Car -200 3350
## 2017-03-26 Groceries -100 3250
## 2017-04-01 Paycheck 1000 4250
plot(your_budget)
There are also functions to quickly update your existing schedules and budgets (e.g. for fast scenario testing):
update_schedule
lets you quickly add and/or remove items from a particular schedule. For example, say that you forgot to include the deposit for a late-received Christmas present:xmas_present <- create_item( name = "Xmas Present"
, amount = 200
, day = "2017-01-01"
)
your_schedule_updated <- update_schedule(your_schedule, add=xmas_present)
update_budget
lets you quickly change the start date, the end date, and/or the initial amount. For example, say that you wanted to update your_budget
to apply through the end of 2017:your_budget_2017 <- update_budget(your_budget, end="2017-12-31")
plot(your_budget_2017)