From 9fa8770469e3f24c22f78c925c56eb9b9d220a85 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sun, 3 Jan 2021 00:26:26 +0100
Subject: [PATCH] Correctly calculate net / Zillmer / alpha/beta/gamma premium
 components

I was wrongly using ifelse, which resulted in a single value that was repeated in the data.frame, rather than an if construct that would have returned a vector with a single non-null entry and 0 for all other entries.

Closes issue #68
---
 .Renviron          | 1 +
 R/InsuranceTarif.R | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 .Renviron

diff --git a/.Renviron b/.Renviron
new file mode 100644
index 0000000..fdad509
--- /dev/null
+++ b/.Renviron
@@ -0,0 +1 @@
+_R_CHECK_DEPENDS_ONLY_=true
diff --git a/R/InsuranceTarif.R b/R/InsuranceTarif.R
index 3bba9d1..12c485c 100644
--- a/R/InsuranceTarif.R
+++ b/R/InsuranceTarif.R
@@ -1268,7 +1268,7 @@ InsuranceTarif = R6Class(
 
 
       # Gross premium = net + zillmeredAlpha + unzillmeredAlpha + beta + gamma premium
-      unit.premiumCF   = ifelse(premiums[["gross"]] == 0, premium.gross * 0, premium.gross / premiums[["gross"]]);
+      unit.premiumCF   = if (premiums[["gross"]] == 0) { premium.gross * 0 } else { premium.gross / premiums[["gross"]] }
       if (values$absPresentValues[t, "premiums.unit"] == 0) {
         premium.gamma    = 0
         premium.beta     = 0
-- 
GitLab