Overview
wealthR is a lightweight, zero-dependency R package for simple financial forecasting.
It is designed to help users model investment growth, savings plans, and inflation effects using base R logic.
The package focuses on small, practical functions that are easy to read, easy to test, and useful for long-term financial planning.
What this package does
The package includes tools to:
- Simulate Investment Growth: Model principal and monthly contributions with compounding interest (Ordinary Annuity).
- Adjust for Inflation: Convert future nominal values into real purchasing-power terms.
- Robust Calculations: Safely handle edge cases, such as 0 parcent interest rates or inflation.
- Base R Visualizations: Generate clean, professional wealth trajectory plots without external dependencies.
Getting started
To begin using the package, install and load it into your environment:
Calculate Nominal Growth
You can project the future value of an initial investment plus monthly contributions. The calc_wealth function calculates the balance for every month in the period.
# Calculate growth over 30 years
raw_wealth <- calc_wealth(
principal = 10000,
monthly = 500,
rate = 0.07,
years = 30
)
head(raw_wealth, 12)Adjust for Inflation
To see what that money will actually buy in the future, use adjust_inflation. This function now automatically detects the time horizon based on the length of your wealth vector.
# Adjust the projection for 3% annual inflation
real_wealth <- adjust_inflation(
amounts = raw_wealth,
inflation_rate = 0.03
)
head(real_wealth, 20)Visualizing the Trajectory
The plot_wealth function provides a quick way to see the growth curve with a shaded area representing total accumulation.
# Compare the nominal vs. inflation-adjusted wealth
plot_wealth(raw_wealth, title = "Nominal Wealth Projection")
plot_wealth(real_wealth, title = "Real Wealth Projection")