From df76d32ce5ebe2e9c5f54a39138f93d34b120fbf Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Mon, 4 Sep 2017 08:32:11 +0000 Subject: [PATCH] Style fixes --- R/deathProbabilities.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/R/deathProbabilities.R b/R/deathProbabilities.R index bc495d2..202cbaa 100644 --- a/R/deathProbabilities.R +++ b/R/deathProbabilities.R @@ -20,13 +20,13 @@ setMethod("deathProbabilities", "mortalityTable.period", #' @describeIn deathProbabilities Return the (cohort) death probabilities of the #' life table given the birth year (if needed) setMethod("deathProbabilities","mortalityTable.ageShift", - function (object, ..., YOB = 1975) { - qx=object@deathProbs * (1 + object@loading); + function(object, ..., YOB = 1975) { + qx = object@deathProbs * (1 + object@loading); shift = ageShift(object, YOB); - if (shift>0) { - qx = c(qx[(shift+1):length(qx)], rep(qx[length(qx)], shift)); - } else if (shift<0) { - qx = c(rep(0, -shift), qx[1:(length(qx)-(-shift))]) + if (shift > 0) { + qx = c(qx[(shift + 1):length(qx)], rep(qx[length(qx)], shift)); + } else if (shift < 0) { + qx = c(rep(0, -shift), qx[1:(length(qx) - (-shift))]) } object@modification(qx) }) @@ -34,23 +34,23 @@ setMethod("deathProbabilities","mortalityTable.ageShift", #' @describeIn deathProbabilities Return the (cohort) death probabilities of the #' life table given the birth year (if needed) setMethod("deathProbabilities","mortalityTable.trendProjection", - function (object, ..., YOB = 1975) { - qx=object@deathProbs * (1 + object@loading); + function(object, ..., YOB = 1975) { + qx = object@deathProbs * (1 + object@loading); if (is.null(object@trend2) || length(object@trend2) <= 1) { ages = object@ages; damping = sapply( ages, - function (age) { object@dampingFunction(YOB + age - object@baseYear) } + function(age) { object@dampingFunction(YOB + age - object@baseYear) } ); finalqx = exp(-object@trend * damping) * qx; } else { # dampingFunction interpolates between the two trends: # The damping functions does NOT give yearly weights, # but rather cumulative weights from the base year until the observation year! - weights = sapply(YOB + 0:(length(qx)-1), object@dampingFunction); + weights = sapply(YOB + 0:(length(qx) - 1), object@dampingFunction); finalqx = qx * exp( -(object@trend * (1 - weights) + object@trend2 * weights) * - (YOB + 0:(length(qx)-1) - object@baseYear)) + (YOB + 0:(length(qx) - 1) - object@baseYear)) } object@modification(finalqx) }) @@ -58,7 +58,7 @@ setMethod("deathProbabilities","mortalityTable.trendProjection", #' @describeIn deathProbabilities Return the (cohort) death probabilities of the #' life table given the birth year (if needed) setMethod("deathProbabilities","mortalityTable.improvementFactors", - function (object, ..., YOB = 1975) { + function(object, ..., YOB = 1975) { qx = object@deathProbs * (1 + object@loading); finalqx = (1 - object@improvement)^(YOB + 0:(length(qx) - 1) - object@baseYear) * qx; object@modification(finalqx) @@ -67,7 +67,7 @@ setMethod("deathProbabilities","mortalityTable.improvementFactors", #' @describeIn deathProbabilities Return the (cohort) death probabilities of the #' life table given the birth year (if needed) setMethod("deathProbabilities","mortalityTable.mixed", - function (object, ..., YOB = 1975) { + function(object, ..., YOB = 1975) { qx1 = deathProbabilities(object@table1, ..., YOB); qx2 = deathProbabilities(object@table2, ..., YOB); mixedqx = (object@weight1 * qx1 + object@weight2 * qx2)/(object@weight1 + object@weight2) * (1 + object@loading); -- GitLab