Using base/stats functions cut() and quantile().
Usage
quantile_cut(
x,
groups,
y = NULL,
na.rm = TRUE,
group.names = NULL,
ordered.f = FALSE,
inc.outs = FALSE,
detail.list = FALSE
)
Arguments
- x
Variable to cut.
- groups
Number of groups.
- y
alternative vector to draw quantile cuts from. Limits has to be within x. Default is NULL.
- na.rm
Remove NA's. Default is TRUE.
- group.names
Names of groups to split to. Default is NULL, giving intervals as names.
- ordered.f
Set resulting vector as ordered. Default is FALSE.
- inc.outs
Flag to include min(x) and max(x) as boarders in case of y!=NULL.
- detail.list
flag to include details or not
Examples
aa <- as.numeric(sample(1:1000,2000,replace = TRUE))
x <- 1:450
y <- 6:750
summary(quantile_cut(aa,groups=4,detail.list=FALSE)) ## Cuts quartiles
#> [1,245] (245,498] (498,756] (756,1e+03]
#> 500 500 500 500