当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R tcut 人年计算因子


R语言 tcut 位于 survival 包(package)。

说明

将 person-year 计算的类别附加到变量,而不会丢失底层的连续表示

用法

tcut(x, breaks, labels, scale=1)
## S3 method for class 'tcut'
levels(x)

参数

x

数字/日期变量

breaks

类别之间的中断,即right-continuous

labels

类别标签

scale

xbreaks 乘以该值。

tcut 类的对象

例子

# For pyears, all time variable need to be on the same scale; but
# futime is in months and age is in years
test <- mgus2
test$years <- test$futime/30.5   # follow-up in years

# first grouping based on years from starting age (= current age)
# second based on years since enrollment (all start at 0)
test$agegrp <- tcut(test$age, c(0,60, 70, 80, 100), 
                     c("<=60", "60-70", "70-80", ">80"))
test$fgrp  <- tcut(rep(0, nrow(test)), c(0, 1, 5, 10, 100),
                   c("0-1yr", "1-5yr", "5-10yr", ">10yr"))

# death rates per 1000, by age group
pfit1 <- pyears(Surv(years, death) ~ agegrp, scale =1000, data=test)
round(pfit1$event/ pfit1$pyears) 

#death rates per 100, by follow-up year and age
# there are excess deaths in the first year, within each age stratum
pfit2 <- pyears(Surv(years, death) ~ fgrp + agegrp, scale =1000, data=test)
round(pfit2$event/ pfit2$pyears)  

也可以看看

cut , pyears

相关用法


注:本文由纯净天空筛选整理自R-devel大神的英文原创作品 Factors for person-year calculations。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。