Surv(time, time2, event,
    type=c('right', 'left', 'interval', 'counting', 'interval2', 'mstate'),
    origin=0)
is.Surv(x)TRUE/FALSE (TRUE = death) or 1/2 (2=death). For
    interval censored data, the status indicator is 0=right censored,
    1=event at time(start, end].  For counting process
    data, event indicates whethe"right", "left", "counting",
    "interval", "interval2" or "mstate".Surv.  There are methods for print,
  is.na, and subscripting survival objects.   Surv objects
  are implemented as a matrix of 2 or 3 columns that has further
  attributes. These include the type (left censored, right censored,
  counting process, etc.) and labels for the states for multi-state
  objects.  Any attributes of the input arguments are also preserved
  in inputAttributes.  This may be useful for other packages that
  have attached further information to data items such as labels; none
  of the routines in the survival package make use of these
  values, however.  In the case of is.Surv, a logical value TRUE if x
  inherits from class "Surv", otherwise an FALSE.
type argument is missing the code assumes a type based
  on the following rules:
  timeandeventin that order.  If there are three unnamed arguments
     they matchtime,time2andevent.mstateis
     assumed.  Otherwise typerightif there is notime2argumement, and typecountingif there is.type argument can usually be omitted.   When the survival type is "mstate" then the status variable will be
   treated as a factor.  The first level of the factor is taken to
   represent censoring and remaining ones a transition to the given state.
   
    Interval censored data can be represented in two ways.  For the first
   use type = "interval" and the codes shown above.  In that usage the
   value of the time2 argument is ignored unless event=3.
   The second approach is to think of each observation as a time
   interval with (-infinity, t) for left censored, (t, infinity) for
   right censored, (t,t) for exact and (t1, t2) for an interval.
   This is the approach used for type = interval2.  Infinite values can
   be represented either by actual infinity (Inf) or NA.
   The second form has proven to be the more useful one.
Presently, the only methods allowing interval censored data are the 
parametric models computed by survreg and survival curves
computed by survfit; for both of these, 
the distinction between open and closed intervals
is unimportant.  
The distinction is important for counting process data and 
the Cox model. 
The function tries to distinguish between the use of 0/1 and 1/2 coding for 
censored data via the condition 
if (max(status)==2). 
If 1/2 coding is used and all the subjects are censored, it will 
guess wrong.
In any questionable case it is safer to use logical coding,
e.g., Surv(time, status==3) would indicate that a 3 is
the code for an event.
For multi-state survival (type= "mstate") the status variable can have multiple levels. The first of these will stand for censoring, and the others for various event types, e.g., causes of death.
Surv objects can be subscripted either as a vector, e.g.
x[1:3] using a single subscript,
in which case the drop argument is ignored and the result will be
a survival object; 
or as a matrix by using two subscripts.
If the second subscript is missing and drop=F
(the default),
the result of the subscripting will be a Surv object, e.g., 
x[1:3,,drop=F],
otherwise the result will be a matrix (or vector), in accordance with
the default behavior for subscripting matrices.
coxph,  
survfit,  
survreg.with(lung, Surv(time, status))
Surv(heart$start, heart$stop, heart$event)Run the code above in your browser using DataLab