Skip to contents

# Easy function for splitting numeric variable in quantiles

Source: `R/quantile_cut.R`
`quantile_cut.Rd`

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 borders in case of y!=NULL.

detail.list

  flag to include details or not

## Value

vector or list with vector and details (length 2)

## 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,261]   (261,514]   (514,758] (758,1e+03]
    #>         501         508         493         498