Author: Triad sou.
Date: 2016-01-04

# Dataset requirements to make Kaplan-Meier plot with RcmdrPlugin.KMggplot2

#### Triad sou.

#### 2016-01-04

`RcmdrPlugin.KMggplot2` depends `survfit` function of `survival` package. Dataset requirements are same as `survfit` function, which works with `Surv` objects.

## `Surv` object

`Surv` objects are generated from `Surv` function. `RcmdrPlugin.KMggplot2` calls as follows:

    survfit(Surv(time = x, event = y, type = "right") ~ z + s + t, .df)

### Arguments

- `time`
  - The follow up time variable.
- `event`
  - The status indicator variable, 0 = alive (censor), 1 = dead (event).
- `type`
  - Character string specifying the type of censoring. `RcmdrPlugin.KMggplot2` can only handle “right” censoring.
- `z`, `s`, `t`
  - The stratum (`z`) and the facet (`s`, `t`) variables (factor variables).
- `.df`
  - A data frame for plotting.

`RcmdrPlugin.KMggplot2` requires a data frame that at least includes `time` and `event` variables, and includes `z`, `s`, `t` if you needs

## Data Example

time | event | trt | sex | marker
--- | --- | --- | --- | ---
17.540935 | 1 | Group-C | M | Low
16.520777 | 1 | Group-A | M | Low
6.530335 | 0 | Group-A | M | High
10.701766 | 0 | Group-B | M | High
4.779544 | 1 | Group-A | M | Low
20.000000 | 0 | Group-C | M | Low
19.527943 | 1 | Group-B | M | Low
13.065791 | 1 | Group-B | M | High
8.710817 | 1 | Group-A | M | High
14.460404 | 1 | Group-B | M | Low

In this case:

- `time`: “time”
- `event`: “event” (0 = alive (censor), 1 = dead (event))
- `z`, `s`, or `t`: “trt”, “sex”, or “marker”