Repository navigation
Expand file tree
/
Copy pathREADME.Rmd
More file actions
91 lines (70 loc) · 2.21 KB
/
Copy pathREADME.Rmd
File metadata and controls
91 lines (70 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# simulreturns <img src="man/figures/logo.png" align="right" height="139" />
<!-- badges: start -->
<!-- badges: end -->
The goal of simulreturns is to give access to user-friendly tools for computing the final value of an investment project.
## Installation
You can install the development version of simulreturns from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("Layalchristine24/simulreturns")
```
## Example
This is a basic example which shows you how to solve compute the final value of an investment of 5000 units after 30 periods, with compound interest and immediate annuities, assuming an expected return of 10\% in average and annuities of 12000 units.
```{r example, echo=TRUE}
library(simulreturns)
library(dplyr)
# Parameters
.n_per <- 30
.v_0 <- 5000
.exp_return <- 10
.compound <- TRUE
.x_yearly <- 12000
.immediate <- TRUE
# Compound return, with immediate annuities
FINAL_VALUE_CMP_IMM_ANNUITIES <- get_final_value(
n_per = .n_per,
v_0 = .v_0,
exp_return = .exp_return,
compound = .compound,
x_yearly = .x_yearly,
immediate = .immediate
)
FINAL_VALUE_CMP_IMM_ANNUITIES
```
```{r summary_final_value}
summary(FINAL_VALUE_CMP_IMM_ANNUITIES)
```
```{r plot_final_value, echo = FALSE}
library(ggplot2)
FINAL_VALUE_CMP_IMM_ANNUITIES %>%
ggplot(aes(x = period, y = final_value)) +
geom_line(linewidth = 1.1) +
theme_light() +
labs(
title = "Investment final value, with compound interest and immediate annuities",
subtitle = paste0("Number of per.: ", .n_per, ", init. capital: ", .v_0, " units, exp. return: ", .exp_return, "%/year, annuities: ", .x_yearly, " units"),
x = "Periods",
y = "Final value after x periods (in units of wished currency)",
caption = paste(
format(Sys.Date(), "%d.%m.%Y"),
"Layal C. Lettry",
sep = ", "
)
) +
theme(
legend.position = "bottom", axis.text = element_text(size = 12),
axis.title = element_text(size = 12)
)
```