r - 生命表中的间隔
问题描述
我正在尝试创建一个具有第一个间隔 [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 )"
解决方案
推荐阅读
- json - 将列类型从 JSONB 更改为 JSON
- c++ - 如何让 PROJ C++ 识别网格目录?
- c++ - 加载共享库时出错:libopencv_imgproc.so.4.5 Clion
- visual-studio - 问题运行单元测试 Visual Studio 2019
- xamarin.forms - 为什么我在 Android 上设置圆角半径时 Xamarin 线性进度条减半?
- google-sheets - ArrayFormula 自动计算特定列
- r - 按子组绘制风险比
- python - 如何关联两个表以了解 Django 的 ManyToMany 字段中包含哪个值?
- npm - 在 Nexus NPM 本地 repo 上重新托管 vsix 包
- javascript - 在循环中将处理程序从类传递到组件