Transformation.apply: Apply a 'Transformation' to a Data Vector and (Normalize the...

Description Usage Arguments Value Examples

View source: R/apply.R

Description

We transform a vector data using a given Transformation, i.e., create a TransformedData object where all elements are the result of the Transformation@forward function. If the parameter normalize is set to TRUE, which it is by default, the transformed data will further be normalized and the transformation is adapted accordingly. In this case, it is ensured that all elements of the produced TransformedData@data vector will be in [0, 1]. If the transformation fails, i.e., produces non-finite, NaN, or NA values, NULL is returned.

Usage

1
2
Transformation.apply(data, transformation, normalize = TRUE,
  negateNormalization = FALSE)

Arguments

data

the data vector to normalize

transformation

the transformation to be applied first

normalize

normalize the result (and modify the transformation accordingly)? ... TRUE by default

negateNormalization

if normalize is TRUE, this parameter decides whether the maximum transformed value should be mapped to 1 (negateNormalization==FALSE) or to 0 (negateNormalization==TRUE)

Value

the corresponding TransformedData instance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
trafo <- Transformation.new(function(x) x*x, sqrt)
data <- c(1, 2, 3, 4)
Transformation.apply(data, trafo, normalize=FALSE)
# An object of class "TransformedData"
# Slot "transformation":
# An object of class "Transformation"
# Slot "forward":
# function (x)
# x * x
#
# Slot "backward":
# function (x)  .Primitive("sqrt")
#
# Slot "data":
# [1]  1  4  9 16
Transformation.apply(data, trafo, normalize=TRUE)
# An object of class "TransformedData"
# Slot "transformation":
# An object of class "Transformation"
# Slot "forward":
# function (x)
# ((x * x - 1)/15)
# <environment: 0x42a5ee8>
#
# Slot "backward":
# function (x)
# sqrt(x = (x * 15) + 1)
# <environment: 0x4085558>
#
#
# Slot "data":
# [1] 0.0000000 0.2000000 0.5333333 1.0000000

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