Skip to contents

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.

Value

A numeric vector of the same length as x.

Details

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

Examples


discount(rep(10, 5), .02)
#> [1] 10.000000  9.803922  9.611688  9.423223  9.238454
discount(rep(10, 5), .02, first = FALSE)
#> [1] 10.000000  9.803922  9.611688  9.423223  9.238454
 
discount(1000, .05, time = 10)
#> [1] 644.6089
discount(1000, .05, period = 2, time = 1:10)
#>  [1] 1000.0000 1000.0000  952.3810  952.3810  907.0295  907.0295  863.8376
#>  [8]  863.8376  822.7025  822.7025
discount(1000, .05, period = 2, time = 1:10, linear = TRUE)
#>  [1] 1000.0000  975.9001  952.3810  929.4286  907.0295  885.1701  863.8376
#>  [8]  843.0192  822.7025  802.8754