Learn R Programming

ggRandomForests (version 1.1.2)

combine.gg_partial: combine two gg_partial objects

Description

The combine.gg_partial function assumes the two gg_partial objects were generated from the same randomForestSRC::rfsrc object. So, the function joins along the gg_partial list item names (one per partial plot variable). Further, we combine the two gg_partial objects along the group variable.

Hence, to join three gg_partial objects together (i.e. for three different time points from a survival random forest) would require two combine.gg_partial calls: One to join the first two gg_partial object, and one to append the third gg_partial object to the output from the first call. The second call will append a single lbls label to the gg_partial object.

Usage

combine.gg_partial(x, y, lbls, ...)

Arguments

x
gg_partial object
y
gg_partial object
lbls
vector of 2 strings to label the combined data.
...
not used

Value

  • gg_partial or gg_partial_list based on class of x and y.

Examples

Run this code
# Load a set of plot.variable partial plot data
data(partial_veteran)

# A list of 2 plot.variable objects
length(partial_veteran)
class(partial_veteran)

class(partial_veteran[[1]])
class(partial_veteran[[2]])

# Create gg_partial objects
ggPrtl.1 <- gg_partial(partial_veteran[[1]])
ggPrtl.2 <- gg_partial(partial_veteran[[2]])

# Combine the objects to get multiple time curves
# along variables on a single figure.
ggpart <- combine.gg_partial(ggPrtl.1, ggPrtl.2,
                             lbls = c("30 day", "6 month"))

# Plot each figure separately
plot(ggpart)

# Get the continuous data for a panel of continuous plots.
ggcont <- ggpart
ggcont$celltype <- ggcont$trt <- ggcont$prior <- NULL
plot(ggcont, panel=TRUE)

# And the categorical for a panel of categorical plots.
ggpart$karno <- ggpart$diagtime <- ggpart$age <- NULL
plot(ggpart, panel=TRUE)

Run the code above in your browser using DataLab