uniformEncode: uniformEncode

Description Usage Arguments Value

View source: R/encodings.R

Description

Puts data from 1 range into another using a linear mapping. i.e. map data in 0-1 to 0-100

Usage

1
2
3
uniformEncode(dt, vars, oldRange = lapply(dt[, vars, with = FALSE],
  function(x) return(c(min(x, na.rm = TRUE), max(x, na.rm = TRUE)))),
  newRange = c(0, 1), encodeNA = NA)

Arguments

dt

Dataset to create object on.

vars

variables you want to include in the encoding.

oldRange

The old range of the variable. This can be user specified if you believe your data does not encompass the entire true range.

newRange

the new range the map the values to. This can either be a vector, or a named list of vectors if you want different ranges for each variable (not typical).

encodeNA

Values to set NA to. Can be a scalar or a named list of scalars (different values for each variable) if you are doing something complicated. If TRUE, NAs will be grouped, but only if they are 'rare'. If they are not rare, NAs will be untouched.

Value

Rare Encoded Object


AnotherSamWilson/helperFuncs documentation built on Oct. 1, 2019, 8:51 p.m.