discount: Discount a Quantity Over Time. Should be a scalar if time is...

View source: R/utils.R

discountR Documentation

Discount a Quantity Over Time. Should be a scalar if time is specified, a vector otherwise

Description

Discount a Quantity Over Time. Should be a scalar if time is specified, a vector otherwise

Usage

discount(x, r, first = FALSE, period = 1, linear = FALSE, time)

Arguments

x

numeric. A quantity to discount.

r

discount rate.

first

logical. Should discounting start at the first value?

period

Number of cycle per unit of discount rate.

linear

logical. Should the discount rate vary linearly along the whole period?

time

The cycle number.

Details

If the unit of discount rate is the year and a cycle duration is 1 month, period should be 12.

Value

A numeric vector of the same length as x.

Examples


discount(rep(10, 5), .02)
discount(rep(10, 5), .02, first = FALSE)
 
discount(1000, .05, time = 10)
discount(1000, .05, period = 2, time = 1:10)
discount(1000, .05, period = 2, time = 1:10, linear = TRUE)


heemod documentation built on July 26, 2023, 5:45 p.m.