Learn R Programming

ggRandomForests (version 1.2.1)

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 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_pbc)

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

class(partial_pbc[[1]])
class(partial_pbc[[2]])

# Create gg_partial objects
ggPrtl.1 <- gg_partial(partial_pbc[[1]])
ggPrtl.2 <- gg_partial(partial_pbc[[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("1 year", "3 years"))
                             
# Plot each figure separately
plot(ggpart)                                  

# Get the continuous data for a panel of continuous plots.
ggcont <- ggpart
ggcont$edema <- ggcont$ascites <- ggcont$stage <- NULL
plot(ggcont, panel=TRUE) 

# And the categorical for a panel of categorical plots.
nms <- colnames(sapply(ggcont, function(st){st}))
for(ind in nms){
   ggpart[[ind]] <- NULL
}
plot(ggpart, panel=TRUE)

Run the code above in your browser using DataLab