bundle_up: Assign numeric values to bundles summing up to a set value

View source: R/skUtils.R

bundle_upR Documentation

Assign numeric values to bundles summing up to a set value

Description

Assign numeric values to bundles summing up to a set value

Usage

bundle_up(
  x,
  maxval,
  group.high = c("own", "na", "error"),
  group.na = c("own", "na", "same", "error")
)

Arguments

x

A numeric vector to bundle up.

maxval

The maximum value a bundle can have.

group.high

What should be done if an individual value exceeds maxval? "own" assigns it to its own bundle, "na" assigns it to NA, and "error" gives an error.

group.na

What should be done if a value is NA? "own" assigns it to its own bundle, "na" assigns it to NA, "same" assigns it to the same bundle as the previous value, and "error" gives an error.

Value

An integer vector of the same length as x, where each value indicates to which bundle the value in x has been assigned.

Author(s)

Sercan Kahveci

Examples

testvec <- sample(c(NA,NA,1:14))
t(cbind(testvec,bundle_up(testvec,maxval=12,group.high="own",group.na="own")))

bundle_up(testvec,maxval=10,group.high="na",group.na="na")


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.