## From vignette(randomForestRegression, package="ggRandomForests")
##
# Load the stored rfsrc and partial coplot data.
data(rfsrc_Boston)
data(partial_coplot_Boston_surf)
# Find the quantile points to create 50 interval groups
rm_pts <- quantile_cuts(rfsrc_Boston$xvar$rm, groups=50)
# Instead of groups, we want the raw rm point values,
# To make the dimensions match, we need to repeat the values
# for each of the 50 points in the lstat direction
rm.tmp <- do.call(c,lapply(rm_pts[-1],
function(grp){rep(grp, 50)}))
# attach the data to the gg_partial_coplot
partial_coplot_Boston_surf$rm <- rm.tmp
srf <- surface_matrix(partial_coplot_Boston_surf, c("lstat", "rm", "yhat"))
# surf3D is in the plot3D package.
library(plot3D)
surf3D(x=srf$x, y=srf$y, z=srf$z,
colkey=FALSE, border = "black", bty="b2",
xlab="Lower Status", ylab="Average Rooms", zlab="Median Value")
Run the code above in your browser using DataLab