Learn R Programming

heemod (version 1.0.2)

discount: 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)

Value

A numeric vector of the same length as x.

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.

Examples

Run this code

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)

Run the code above in your browser using DataLab