# Load libraries library(budgetr) library(pander) library(knitr)
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
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:
rm(list=ls())
# 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 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 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.