Expense reporting using R for a multi-user setup
Provided we have an expense data which is suitable categorised, we can filter it using parameters and generate various plots. Useful when multiple users are adding data to the same file.
- There is a dummy data file
data/usable.csvwhich will be used in this case - The data file is a csv with the following format: "Date", "Amount", "Description", "Category", "User"
- Date is in the format "%Y-%m-%d"
- Amount is numeric
- Description, Category and User are characters and surrounded by quotes
- R
- ggplot2
- A csv file
data/usable.csvappropriately structured (see above)
Rscript rexpense.r <parameters>
- Timespan:
day | week | month | year - Only certain Categories:
only Category_1 | Category_2 | ...| Category_nwhereCategory_iis one of theCategoryin the csv file. Can be used multiple times to include multiple categories. - Exclude Categories:
no Category1 | Category2 | ...| Categoryn. Can be used multiple times. - Date filters:
from | to <Date in "%Y-%m-%d" | date_string>.<date_string>can be:thisweek,thismonth,thisyearto denote starting date or ending date, if used withfromortorespectively. Additional<date_string>that can be used withfrom:lastweek,lastmonth. - Only one user:
person User1 | User2 | ... | Usern - As x axis:
xvar <variable_label>, default istimeS(timeSis day/week/month/year, whatever is specified before). Possible<variable_label>:timeS | User | Category | Amount | Descriptionand format strings:a | A | m | y | dfor ( short week | week | month | year | day) - As y axis:
yvar <variable_label>, default isAmount. Same<variable_label>are allowed as inxval - Denote separation using color:
fillvar <variable_label>, usuallyCategory - To show separate bar graph next to each other:
beside - Separate pictures under same axis convention (facet-wrap):
facetvat <variable_label>, usuallyUser - Add a budget line with
budget <numerical value> - To show number:
number - Show value of all entries:
showval, ugly for now;shoadownot functional default.ris related to all the parameters
- Plot:
data/ggplot.csv - Filtered data in csv:
data/filtered.csv
The following image was created using:
Rscript rexpense.r facetvar Category fillvar User month

Rscript rexpense only Category3 xvar User yvar Amount(Which user spends more for Category3?)Rscript rexpense.r xvar User yvar Category fillvar Category(Which user spends how much on which category?)Rscript rexpense.r xvar a yvar User fillar user(Who spends more on which weekday?)Rscript rexpense.r xvar a only Category2 fillvar user(Which month had most spending on Category2, user-wise?)