tcut                package:survival                R Documentation

_F_a_c_t_o_r_s _f_o_r _p_e_r_s_o_n-_y_e_a_r _c_a_l_c_u_l_a_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Attaches categories for person-year calculations to a variable
     without losing the underlying continuous representation

_U_s_a_g_e:

     tcut(x, breaks, labels, scale=1)

_A_r_g_u_m_e_n_t_s:

       x: numeric/date variable 

  breaks: breaks between categories, which are right-continuous 

  labels: labels for categories 

   scale: Multiply 'x' and 'breaks' by this.

_V_a_l_u_e:

     An object of class 'tcut'

_S_e_e _A_l_s_o:

     'cut', 'pyears'

_E_x_a_m_p_l_e_s:

     mdy.date <- function(m,d,y)
        as.Date(paste(ifelse(y<100, y+1900, y), m, d, sep='/'))
     temp1 <- mdy.date(6,6,36)
     temp2 <- mdy.date(6,6,55)# Now compare the results from person-years
     #
     temp.age <- tcut(temp2-temp1, floor(c(-1, (18:31 * 365.24))),
             labels=c('0-18', paste(18:30, 19:31, sep='-')))
     temp.yr  <- tcut(temp2, mdy.date(1,1,1954:1965), labels=1954:1964)
     temp.time <- 3700   #total days of fu
     py1 <- pyears(temp.time ~ temp.age + temp.yr, scale=1) #output in days
     py1

