Learn R Programming

decisionSupport (version 1.114)

discount: Discount time series for Net Present Value (NPV) calculation

Description

This function discounts values along a time series, applying the specified discount rate. It can also calculate the Net Present Value (NPV), which is the sum of these discounted values.

Usage

discount(x, discount_rate, calculate_NPV = FALSE)

Value

If calculate_NPV=TRUE, the function returns the Net Present Value (NPV) as a numeric value. If calculate_NPV=FALSE, the time-discounted values are returned as a numeric vector.

Arguments

x

numeric vector, typically containing time series data of costs or benefits

discount_rate

numeric; the discount rate (in percent), expressing the time preference of whoever is evaluating these data economically

calculate_NPV

boolean; if set to TRUE, the discounted time values are summed, otherwise, they are returned as a vector

Author

Eike Luedeling

Examples

Run this code

x<-c(3,6,2,5,4,3,9,0,110)
discount_rate<-5

discount(x,discount_rate)
discount(x,discount_rate,calculate_NPV=TRUE)


Run the code above in your browser using DataLab