cut_fast: Fast cut function

View source: R/cut_fast.R

cut_fastR Documentation

Fast cut function

Description

This function is a fast version of cut that will put every element of x in one of the intervals created by breaks.

Usage

cut_fast(x = c(), breaks = c())

Arguments

x

Numeric vector of elements to put into segments

breaks

Numeric vector of breaks

Details

Each interval is left closed and right opened, example: '[0,1)'.

If -Inf or/and +Inf are not in the vector 'breaks', it will be added to it.

If none of the elements are out of the intervales between the breaks, then the factor returned is only constituted of the breaks intervals. Else, +/-Inf will be added.

Value

factor of intervals

Examples

cut_fast(c(0,0.2,3,5),c(0,1,2,3,4)) #will contain +Inf
cut_fast(c(0,0.2,3),c(0,1,2,3,4)) #will only contain the specific intervals
cut_fast(c(-1,0.2,3),c(0,1,2,3,4)) #will contain -Inf


bronnimannj/jbutilities documentation built on July 2, 2023, 4:09 p.m.