quantile_pts: Find points evenly distributed along the vectors values.

View source: R/quantile_pts.R

quantile_ptsR Documentation

Find points evenly distributed along the vectors values.

Description

This function finds point values from a vector argument to produce groups intervals. Setting groups=2 will return three values, the two end points, and one mid point (at the median value of the vector).

The output can be passed directly into the breaks argument of the cut function for creating groups for coplots.

Usage

quantile_pts(object, groups, intervals = FALSE)

Arguments

object

vector object of values.

groups

how many points do we want

intervals

should we return the raw points or intervals to be passed to the cut function

Value

vector of groups+1 cut point values.

See Also

cut gg_partial_coplot

Examples

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)


ggRandomForests documentation built on Sept. 1, 2022, 5:07 p.m.