Learn R Programming

clustcurv (version 3.0.1)

autoplot.clustcurves: Visualization of clustcurves objects with ggplot2 graphics

Description

Useful for drawing the estimated functions grouped by color and the centroids (mean curve of the curves pertaining to the same group).

Usage

# S3 method for clustcurves
autoplot(
  object = object,
  groups_by_colour = TRUE,
  centers = FALSE,
  conf.int = FALSE,
  censor = FALSE,
  xlab = "Time",
  ylab = "Survival",
  interactive = FALSE,
  ...
)

Value

A ggplot object, so you can use common features from ggplot2 package to manipulate the plot.

Arguments

object

Object of clustcurves class.

groups_by_colour

A specification for the plotting groups by color.

centers

Draw the centroids (mean of the curves pertaining to the same group) into the plot. By default it is FALSE.

conf.int

Only for survival curves. Logical flag indicating whether to plot confidence intervals.

censor

Only for survival curves. Logical flag indicating whether to plot censors.

xlab

A title for the x axis.

ylab

A title for the y axis.

interactive

Logical flag indicating if an interactive plot with plotly is produced.

...

Other options.

Author

Nora M. Villanueva and Marta Sestelo.

Details

See help page of the function ggfortify::autoplot.survfit().

Examples

Run this code

library(survival)
library(clustcurv)
library(ggplot2)
library(ggfortify)

# Survival


cl2 <- ksurvcurves(time = veteran$time, status = veteran$status,
x = veteran$celltype, k = 2, algorithm = "kmeans")

autoplot(cl2)
autoplot(cl2, groups_by_colour = FALSE)
autoplot(cl2, centers = TRUE)


# \donttest{
# Regression

r2 <- kregcurves(y = barnacle5$DW, x = barnacle5$RC,
z = barnacle5$F, k = 2, algorithm = "kmeans")

autoplot(r2)
autoplot(r2, groups_by_colour = FALSE)
autoplot(r2, groups_by_colour = FALSE, interactive = TRUE)
autoplot(r2, centers = TRUE)

# }

Run the code above in your browser using DataLab