R Under development (unstable) (2024-09-28 r87201 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(lifecontingencies) Package: lifecontingencies Authors: Giorgio Alfredo Spedicato [aut, cre] (), Christophe Dutang [ctb] (), Reinhold Kainhofer [ctb] (), Kevin J Owens [ctb], Ernesto Schirmacher [ctb], Gian Paolo Clemente [ctb] (), Ivan Williams [ctb] Version: 1.3.12 Date: BugReport: https://github.com/spedygiorgio/lifecontingencies/issues > pxtvect <- pxt > > #strange example of non consecutive integers > x <- 0:10*10 > y <- 0:9 > lx <- c(100, 99, 98, 97, 96, 93, 86, 73, 50, 17) > > try( + freTH0002 <- new("lifetable", x=x, lx=lx) + ) Error in .local(.Object, ...) : length of x and lx must be equal > > freTH0002 <- new("lifetable", x=y, lx=lx) > > pXt <- Vectorize(pxt, "x") > > n <- length(y) > cbind(c(lx, 0), c(lx[-1] / lx[-n], 0, 0), pxtvect(freTH0002, x=0:10, t=1), pXt(freTH0002, x=0:10, t=1)) [,1] [,2] [,3] [,4] [1,] 100 0.9900000 0.9900000 0.9900000 [2,] 99 0.9898990 0.9898990 0.9898990 [3,] 98 0.9897959 0.9897959 0.9897959 [4,] 97 0.9896907 0.9896907 0.9896907 [5,] 96 0.9687500 0.9687500 0.9687500 [6,] 93 0.9247312 0.9247312 0.9247312 [7,] 86 0.8488372 0.8488372 0.8488372 [8,] 73 0.6849315 0.6849315 0.6849315 [9,] 50 0.3400000 0.3400000 0.3400000 [10,] 17 0.0000000 0.0000000 0.0000000 [11,] 0 0.0000000 0.0000000 0.0000000 > > > #strange example of plateau > y <- 0:10 > lx <- c(100, 99, 98, 97, 96, 96, 96, 96, 96, 96, 96) > > freTH0002 <- new("lifetable", x=y, lx=lx) > > n <- length(x) > cbind(c(lx[-1] / lx[-n], 0), pxtvect(freTH0002, x=y, t=1), pXt(freTH0002, x=y, t=1)) [,1] [,2] [,3] [1,] 0.9900000 0.9900000 0.9900000 [2,] 0.9898990 0.9898990 0.9898990 [3,] 0.9897959 0.9897959 0.9897959 [4,] 0.9896907 0.9896907 0.9896907 [5,] 1.0000000 1.0000000 1.0000000 [6,] 1.0000000 1.0000000 1.0000000 [7,] 1.0000000 1.0000000 1.0000000 [8,] 1.0000000 1.0000000 1.0000000 [9,] 1.0000000 1.0000000 1.0000000 [10,] 1.0000000 1.0000000 1.0000000 [11,] 0.0000000 0.0000000 0.0000000 > > > proc.time() user system elapsed 1.09 0.18 1.29