% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.gg_partial.R
\name{plot.gg_partial_rfsrc}
\alias{plot.gg_partial_rfsrc}
\title{Plot a \code{\link{gg_partial_rfsrc}} object}
\usage{
\method{plot}{gg_partial_rfsrc}(x, ...)
}
\arguments{
\item{x}{A \code{\link{gg_partial_rfsrc}} object.}

\item{...}{Not currently used.}
}
\value{
A \code{ggplot} (or \code{patchwork}) object.  When both continuous
and categorical variables are present the two panels are combined
vertically via \code{patchwork::wrap_plots()}.
}
\description{
Renders the partial dependence curves from \code{\link{gg_partial_rfsrc}}
as a ggplot2 figure.  The layout adapts automatically to what the object
contains.
}
\details{
For a standard regression or classification forest, continuous predictors
are drawn as line plots and categorical predictors as bar charts, both
faceted by variable name -- the same arrangement as
\code{\link{plot.gg_partial}}.

For a survival forest, each call to \code{partial.rfsrc} returns a predicted
quantity (survival probability, cumulative hazard function, or mortality) at
one or more chosen time horizons.  When a \code{time} column is present in
the data, each horizon becomes a separate coloured curve over the predictor's
value, still faceted by variable.  The y-axis label (\dQuote{Predicted
Survival}, \dQuote{Predicted CHF}, or \dQuote{Predicted Mortality}) tracks
the \code{partial.type} attribute set by \code{gg_partial_rfsrc()}.

For a two-variable interaction surface (when \code{xvar2.name} was supplied
to \code{gg_partial_rfsrc}), the secondary variable's levels become
separate coloured lines, faceted by the primary predictor.
}
\examples{
## ------------------------------------------------------------
## Regression forest -- one continuous curve per variable
## ------------------------------------------------------------
set.seed(42)
airq <- na.omit(airquality)
rfsrc_airq <- randomForestSRC::rfsrc(Ozone ~ ., data = airq, ntree = 50)

pd <- gg_partial_rfsrc(rfsrc_airq, xvar.names = c("Wind", "Temp"),
                       n_eval = 10)
plot(pd)

\donttest{
## ------------------------------------------------------------
## Survival forest -- one curve per requested time horizon,
## faceted by variable. Y-axis label tracks `partial.type`.
## ------------------------------------------------------------
# randomForestSRC's formula parser requires the unqualified Surv() symbol;
# it Depends on `survival`, so Surv is on the search path once
# randomForestSRC is loaded.
data(veteran, package = "randomForestSRC")
set.seed(42)
rfsrc_v <- randomForestSRC::rfsrc(Surv(time, status) ~ .,
                                  data = veteran, ntree = 50)
ti  <- rfsrc_v$time.interest
t30 <- ti[which.min(abs(ti - 30))]
t90 <- ti[which.min(abs(ti - 90))]

# Default partial.type = "surv" -> y-axis "Predicted Survival"
pd_s <- gg_partial_rfsrc(rfsrc_v, xvar.names = "age",
                         partial.time = c(t30, t90), n_eval = 8)
plot(pd_s)

# partial.type = "chf" -> y-axis "Predicted CHF"
pd_c <- gg_partial_rfsrc(rfsrc_v, xvar.names = "age",
                         partial.time = c(t30, t90),
                         partial.type = "chf", n_eval = 8)
plot(pd_c)
}

}
\seealso{
\code{\link{gg_partial_rfsrc}}, \code{\link{plot.gg_partial}}
}
