View source: R/time_period_to_months.R
period_to_months | R Documentation |
The function splits rows with a time period longer than one month to multiple rows with a time period of exactly one month each. Values in numeric columns (e.g. exposure or premium) are divided over the months proportionately.
period_to_months(df, begin, end, ...)
df |
data.frame |
begin |
column in |
end |
column in |
... |
numeric columns in |
In insurance portfolios it is common that rows relate to periods longer than one month. This is for example problematic in case exposures per month are desired.
Since insurance premiums are constant over the months, and do not depend on the number of days per month, the function assumes that each month has the same number of days (i.e. 30).
data.frame with same columns as in df
, and one extra column
called id
Martin Haringa
library(lubridate)
portfolio <- data.frame(
begin1 = ymd(c("2014-01-01", "2014-01-01")),
end = ymd(c("2014-03-14", "2014-05-10")),
termination = ymd(c("2014-03-14", "2014-05-10")),
exposure = c(0.2025, 0.3583),
premium = c(125, 150))
period_to_months(portfolio, begin1, end, premium, exposure)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.