# earnPremium.R
#
require(plyr)
earnPremium <- function(data, asof)
as.matrix(
adply(.data = data,
.margins = 1,
.fun = function(x) diff(approxfun(c(x[["effectivedate"]], x[["expirationdate"]]), c(0, x[["writtenpremium"]]), rule = 2)(asof))
)[-(1:length(data))]
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.