knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

irr2

DOI

The goal of irr2 is to calculate IRR and NPV. The related functions inspired by @Ellis2019CBA.

Installation

You can install the released version of irr2 from CRAN with:

install.packages("irr2")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("JiaxiangBU/irr2")

Example

This is a basic example which shows you how to solve a common problem:

library(irr2)
## basic example code

There is a stream of cash flows, down payment with 2200, and next pay back 752.97 each month. To calcuate the IRR per year.

cf1 <- c(-2200, rep(752.9700, 3))
cf1
irr_m <- irr(cf = cf1)
irr_m
((irr_m/100+1)^12-1)*100

If the discount rate is 2%, calcuate NPV of this cash flows. If the discount rate is 1%, calcuate NPV of this cash flows.

npv(discount = 2, cf = cf1)
npv(discount = 1.33299, cf = cf1)
npv(discount = 1, cf = cf1)
irr2 <- irr(c(-100, 39, 59, 55, 20))/100
irr2
-100 +
    39/(1+irr2)^1 +
    59/(1+irr2)^2 +
    55/(1+irr2)^3 +
    20/(1+irr2)^4

Citations

citations <- add2pkg::add_zenodo_citation("README.Rmd")
cat(citations$Cite)
cat(paste0("```BibTex\n",citations$BibTex,"\n```"))
cat(citations$Comments)

r add2pkg::add_disclaimer("Jiaxiang Li")

Reference {-}



JiaxiangBU/irr2 documentation built on Jan. 20, 2020, 9:16 a.m.