Transformation.makePositive: Create a Transformation which Shifts all Values of a Data...

Description Usage Arguments Value Examples

View source: R/makePositive.R

Description

A transformation is created which could be used to shift all elements of a data vector into the positive range. This is a utility function which can be applied before log-scaling or 1/x scaling of data. The transformation will be a linear shift and not involve scaling or squaring.

Usage

1

Arguments

data

the data vector

zeroAllowed

is it ok if the transformation of the data vector would produce 0 values?

Value

a Transformation which would transform the data vector into the positive domain, or NULL if no such transformation can be provided

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data <- c(-1, 0, 0.1, 2)
trafo <- Transformation.makePositive(data, zeroAllowed=TRUE)
trafo@forward(data)
# [1] 0.0 1.0 1.1 3.0
trafo@backward(trafo@forward(data))
# [1] -1.0  0.0  0.1  2.0
trafo@forward
# function (x)
# x + 1
# <environment: 0x4bee3c0>
trafo@complexity
# [1] 1
trafo <- Transformation.makePositive(data, zeroAllowed=FALSE)
trafo@forward(data)
# [1] 0.0625 1.0625 1.1625 3.0625
trafo@backward(trafo@forward(data))
# [1] -1.0  0.0  0.1  2.0
trafo@complexity
# [1] 2

thomasWeise/dataTransformeR documentation built on May 14, 2019, 8:03 a.m.