autoplotTen {survMisc} | R Documentation |
Generate a ggplot
for a survfit
or ten
object
Description
Generate a ggplot
for a survfit
or ten
object
Usage
autoplot(object, ...)
## S3 method for class 'ten'
autoplot(
object,
...,
title = "Marks show times with censoring",
type = c("single", "CI", "fill"),
alpha = 0.05,
ciLine = 10,
censShape = 3,
palette = c("Dark2", "Set2", "Accent", "Paired", "Pastel1", "Pastel2", "Set1",
"Set3"),
jitter = c("none", "noEvents", "all"),
tabTitle = "Number at risk by time",
xLab = "Time",
timeTicks = c("major", "minor", "days", "months", "custom"),
times = NULL,
yLab = "Survival",
yScale = c("perc", "frac"),
legend = TRUE,
legTitle = "Group",
legLabs = NULL,
legOrd = NULL,
titleSize = 15,
axisTitleSize = 15,
axisLabSize = 10,
survLineSize = 0.5,
censSize = 5,
legTitleSize = 10,
legLabSize = 10,
fillLineSize = 0.05,
tabTitleSize = 15,
tabLabSize = 5,
nRiskSize = 5
)
## S3 method for class 'stratTen'
autoplot(
object,
...,
title = NULL,
type = c("single", "CI", "fill"),
alpha = 0.05,
ciLine = 10,
censShape = 3,
palette = c("Dark2", "Set2", "Accent", "Paired", "Pastel1", "Pastel2", "Set1",
"Set3"),
jitter = c("none", "noEvents", "all"),
tabTitle = "Number at risk by time",
xLab = "Time",
timeTicks = c("major", "minor", "days", "months", "custom"),
times = NULL,
yLab = "Survival",
yScale = c("perc", "frac"),
legend = TRUE,
legTitle = "Group",
legLabs = NULL,
legOrd = NULL,
titleSize = 15,
axisTitleSize = 15,
axisLabSize = 10,
survLineSize = 0.5,
censSize = 5,
legTitleSize = 10,
legLabSize = 10,
fillLineSize = 0.05,
tabTitleSize = 15,
tabLabSize = 5,
nRiskSize = 5
)
## S3 method for class 'survfit'
autoplot(
object,
...,
title = "Marks show times with censoring",
type = c("single", "CI", "fill"),
alpha = 0.05,
ciLine = 10,
censShape = 3,
palette = c("Dark2", "Set2", "Accent", "Paired", "Pastel1", "Pastel2", "Set1",
"Set3"),
jitter = c("none", "noEvents", "all"),
tabTitle = "Number at risk by time",
xLab = "Time",
timeTicks = c("major", "minor", "weeks", "months", "custom"),
times = NULL,
yLab = "Survival",
yScale = c("perc", "frac"),
legend = TRUE,
legLabs = NULL,
legOrd = NULL,
legTitle = "Group",
titleSize = 15,
axisTitleSize = 15,
axisLabSize = 10,
survLineSize = 0.5,
censSize = 5,
legTitleSize = 10,
legLabSize = 10,
fillLineSize = 0.05,
tabTitleSize = 15,
tabLabSize = 5,
nRiskSize = 5,
pVal = FALSE,
sigP = 1,
pX = 0.1,
pY = 0.1
)
Arguments
object |
An object of class |
... |
Additional arguments (not implemented). |
title |
Title for survival plot. |
type |
|
alpha |
Opacity of lines indicating confidence intervals
or filled rectangles. Should be in range |
ciLine |
Confidence interval line type. See 'line type specification' in
|
censShape |
Shape of marks to indicate censored onservations.
|
palette |
Options are taken from color_brewer.
|
jitter |
By default,
|
tabTitle |
Table title.
|
xLab |
Label for |
timeTicks |
Numbers to mark on the
|
times |
Vector of custom times to use for |
yLab |
Label for |
yScale |
Display for point on
–Legend arguments:
|
legend |
If |
legTitle |
Legend title. |
legLabs |
Legend labels. These can be used to replace the names
of the covariate groups ('strata' in the case of a |
legOrd |
Legend order.
|
titleSize |
Title size for survival plot. |
axisTitleSize |
Title size for axes. |
axisLabSize |
Title size for labels on axes. |
survLineSize |
Survival line size. |
censSize |
Size of marks to indicate censored onservations. |
legTitleSize |
Title size for legend. |
legLabSize |
Legend labels width and height. |
fillLineSize |
Line size surrouding filled boxes. |
tabTitleSize |
Table title text size. |
tabLabSize |
Table legend text size. |
nRiskSize |
Number at risk - text size.
|
pVal |
If |
sigP |
No. of significant digits to display in |
pX |
Location of |
pY |
Location of |
Note
autoplot.survfit
may be deprecated after packageVersion 0.6.
Please try to use autoplot.ten
instead.
Author(s)
Chris Dardis. autoplot.survfit
based on existing work by
R. Saccilotto, Abhijit Dasgupta, Gil Tomas and Mark Cowley.
See Also
?ggplot2::ggplot_build
Examples
## examples are slow to run; see vignette for output from these
## Not run:
### autoplot.ten
data("kidney", package="KMsurv")
t1 <- ten(survfit(Surv(time, delta) ~ type, data=kidney))
autoplot(t1)
autoplot(t1, type="fill", survLineSize=2, jitter="all")
autoplot(t1, timeTicks="months",
type="CI", jitter="all",
legLabs=c("surgical", "percutaneous"),
title="Time to infection following catheter placement \n
by type of catheter, for dialysis patients",
titleSize=10, censSize=2)$plot
t2 <- ten(survfit(Surv(time=time, event=delta) ~ 1, data=kidney))
autoplot(t2, legLabs="")$plot
autoplot(t2, legend=FALSE)
data("rectum.dat", package="km.ci")
t3 <- ten(survfit(Surv(time, status) ~ 1, data=rectum.dat))
## change confidence intervals to log Equal-Precision confidence bands
ci(t3, how="nair", tL=1, tU=40)
autoplot(t3, type="fill", legend=FALSE)$plot
## manually changing the output
t4 <- ten(survfit(Surv(time, delta) ~ type, data=kidney))
(a4 <- autoplot(t4, type="CI", alpha=0.8, survLineSize=2)$plot)
## change default colors
a4 + list(ggplot2::scale_color_manual(values=c("red", "blue")),
ggplot2::scale_fill_manual(values=c("red", "blue")))
## change limits of y-axis
suppressMessages(a4 + ggplot2::scale_y_continuous(limits=c(0, 1)))
## End(Not run)
## Not run:
data("pbc", package="survival")
t1 <- ten(Surv(time, status==2) ~ trt + strata(edema), data=pbc, abbNames=FALSE)
autoplot(t1)
## End(Not run)
### autoplot.survfit
## Not run:
data(kidney, package="KMsurv")
s1 <- survfit(Surv(time, delta) ~ type, data=kidney)
autoplot(s1, type="fill", survLineSize=2)
autoplot(s1, type="CI", pVal=TRUE, pX=0.3,
legLabs=c("surgical", "percutaneous"),
title="Time to infection following catheter placement \n
by type of catheter, for dialysis patients")$plot
s1 <- survfit(Surv(time=time, event=delta) ~ 1, data=kidney)
autoplot(s1, legLabs="")$plot
autoplot(s1, legend=FALSE)$plot
data(rectum.dat, package="km.ci")
s1 <- survfit(Surv(time, status) ~ 1, data=rectum.dat)
## change confidence intervals to log Equal-Precision confidence bands
if (require("km.ci")) {
km.ci::km.ci(s1, method="logep")
autoplot(s1, type="fill", legend=FALSE)$plot
}
## manually changing the output
s1 <- survfit(Surv(time, delta) ~ type, data=kidney)
g1 <- autoplot(s1, type="CI", alpha=0.8, survLineSize=2)$plot
## change default colors
g1 + ggplot2::scale_colour_manual(values=c("red", "blue")) +
ggplot2::scale_fill_manual(values=c("red", "blue"))
## change limits of y-axis
g1 + ggplot2::scale_y_continuous(limits=c(0, 1))
## End(Not run)