| quantile_pts | R Documentation |
This helper wraps quantile to create well-spaced
cut points for conditioning plots. When intervals = TRUE the lower
boundary is nudged down so that cut() treats the minimum value as a
valid observation.
The output can be passed directly into the breaks argument of the
cut function for creating groups for coplots.
quantile_pts(object, groups, intervals = FALSE)
object |
Numeric vector of predictor values. |
groups |
Number of quantile points (or intervals) to compute. |
intervals |
Logical indicating whether to return interval boundaries
suitable for |
Numeric vector of quantile points. When intervals = TRUE
the result is strictly increasing and can be supplied to cut() to
produce groups balanced strata.
cut
data(Boston, package = "MASS")
rfsrc_boston <- randomForestSRC::rfsrc(medv ~ ., Boston)
# To create 6 intervals, we want 7 points.
# quantile_pts will find balanced intervals
rm_pts <- quantile_pts(rfsrc_boston$xvar$rm, groups = 6, intervals = TRUE)
# Use cut to create the intervals
rm_grp <- cut(rfsrc_boston$xvar$rm, breaks = rm_pts)
summary(rm_grp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.