當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。