首页 > 解决方案 > 生命表中的间隔

问题描述

我正在尝试创建一个具有第一个间隔 [1, 1000) 的生命表,但是我的代码给出了 [0,1000),因为我的间隔长度为 1000。

如何获得 [1,1000) 的第一个区间?

    #Input the interval width for the life table.
IntWidth = 1000

#Input the number of interval for the life table.
Interval = 5

#Define them as empty.
CenCode = 0
Right = NULL
Left = NULL

#Fill in the left and right end-points of the interval.
for (i in 1:Interval){
  Left[i] = (i - 1)*IntWidth
  Right[i] = i*IntWidth
}

#Make the intervals.
Int = paste("[", paste(Left, Right, sep = " , "), ")")
Int

[1] "[ 0 , 1000 )"    "[ 1000 , 2000 )" "[ 2000 , 3000 )" "[ 3000 , 4000 )"
[5] "[ 4000 , 5000 )"

标签: rsurvival-analysis

解决方案


推荐阅读