| ledger-R-report.R | Moar eyecandycd ledger-R-report/ And stacked area plots for better view of percentage per month | |
| LICENSE | Initial commit | |
| README.md | Moar eyecandycd ledger-R-report/ And stacked area plots for better view of percentage per month | |
ledger-R-report
Personnal (read "Strongly opinionated") R code to make sense of ledger-cli reports. Given a basic csv export from ledger-cli (Monthly formatted), it computes some stats (per year) and plots.
Reported stats :
- quartiles (Five-number summary) ;
- mean and standard deviation ;
- total per account (currency and percentage), "parentAccount".
Reported plots :
- amount per account and month ;
- stacked amount per account and month ;
- boxplots per account per year (visual equivalent to the five-number summary).
Installation
Just download the R file, as simple as it gets.
In addition to the basic ones, multiple R package are necessary though :
- readr ;
- dplyr ;
- tidyr ;
- ggplot2.
Those may be overkill for this use, but most people would have them already installed anyway. Each package is called right before their use in the code.
Usage
Simply run the following snippet :
./ledger-R-report.R [OPTIONS] file.ledger
Options are provided :
- --help - Print help text ;
- --index - "Privacy friendly" output with relative values instead of absolute ;
- --no-stat - No summary statistics (Saved as
/tmp/summary.csv) ; - --no-plot - No plots (Saved as Rplots.pdf).
The code is pretty simple due to the format of the ledger's month export which only includes the date, account, currency, and amount.
Note that I only use one currency, and split my logs per year (which may or not generate a bias to the summary depending on recent life changes). The official documentation presents a way to split compound logs. If multiple years are in the same file, don't forget to remove the second section of code which is used to keep only the last entry year.
Contributing
Go fork yourself ; Unless I feel the need for it I probably won't update this code which I built for my own use. It's only publicly shared 'cause I thought other solutions were bloated due to support for uncommon cases, and some people may feel the same way about it.
If I ever update this, it would be to add eye-candy to the plots which are still pretty ugly as it is.
See also
- https://ledger-cli.org/doc/ledger3.html#Visualizing-with-Gnuplot
- https://www.sundialdreams.com/report-scripts-for-ledger-cli-with-gnuplot/
- https://github.com/esovetkin/ledger-plots
- https://github.com/trevorld/r-ledger
Licence
The code is licensed under GPL3.0+.