Compute a Step Function

DESCRIPTION:

Computes a left- or right-continuous step function. This function is deprecated.

USAGE:

stepfun(datax, datay=<<see below>>, type="left")

REQUIRED ARGUMENTS:

datax, datay
numeric vectors, or a list with components named datax and datay giving the locations of the jumps in the function. The values in datax must be in increasing order.

OPTIONAL ARGUMENTS:

type
the type of step function to compute. If type="left", the given points in datax and datay are at the left end of the level steps of the function; this gives a right-continuous function. If type="right", the given points are at the right end of the level steps of the function; this gives a left-continuous function. Only the first character of the string is needed.

VALUE:

a list with components x and y, described below. The return value from stepfun is suitable for passing in to the functions plot, points, and lines.
x
a vector of the unique values in the input argument datax with all but one of the end values repeated.
y
values of the step function taken from the input datay.

DETAILS:

When type="left", each element of the input datay is for the corresponding datax element and the next datax element. For type="right", each element of datay is for the corresponding datax element and the previous datax element.

The type graphics parameter can be set to "s" or "S" to plot step functions. See the help file for par for more details.

SEE ALSO:

, .

EXAMPLES:

fit <- survfit(Surv(futime, fustat), data=ovarian)
plot(stepfun(fit$time, fit$surv), type='l')
# Add 95% confidence intervals.
oldpar <- par(err=-1)  # Avoid the "Lines out of bounds" messagges
lines(stepfun(fit$time, exp(log(fit$surv) + 1.96*fit$std.err)))
lines(stepfun(fit$time, exp(log(fit$surv) - 1.96*fit$std.err)))
par(oldpar)  # Turn graphics warnings back on