Free Access Week-  Data Engineering + BI
Data engineering and BI courses are free!
Free AI Access Week from June 2-8

icarus (version 0.3.2)

regroupModalities: Regroup elements of a vector

Description

Regroup the contiguous elements of a vector under a single value. Which elements should be regrouped is indicated by the rows of a matrix. Output vector is NOT a factor.

Usage

regroupModalities(column, regroupMatrix, modalities = NULL)

Value

Column vector with regrouped modalities

Arguments

column

Column vector which values are going to be replaced

regroupMatrix

Bounds of the values to regroup under the same modality

modalities

Specify the values of the modalities to use. Must match number of rows of regroupMatrix If not specified, replacement modalities will be 1:length(column)

Examples

Run this code
regroupModalities(c(1:20), rbind(c(0,5),c(6,18),c(19,Inf)))
# Returns : [1] 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3

Run the code above in your browser using DataLab