GetTransforms: GetTransforms

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Returns a function that will re-apply the transformations that have been applied to a CausataData obejct to another data frame.

Usage

1
2
## S3 method for class 'CausataData'
GetTransforms(this, ...)

Arguments

this

A CausataData object.

...

Unused extra arguments.

Details

As transformations are applied to the CausataData object, they are recorded. This function returns a function that will apply these transformations, in order, as they were applied to the data frame in the CausataData object. This can be used to validate that transformations work as expected on new data, and are used in model validation.

Value

A function that accepts a data.frame as an argument and returns a transformed data.frame.

Author(s)

David Barker (support@causata.com)

See Also

CausataData.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Create a data frame with a factor that has 5 levels.
df <- data.frame(var__AP=c("a", "a", "a",  "b", "b",  "c", "d", "e", NA))
caustaData <- CausataData(df, rep(0,nrow(df)))

# Merge the smaller levels so the factor has 3 levels.
# The remaining levels will be a, b, and Other.
caustaData <- MergeLevels(caustaData, max.levels=3)

# Get a function that will re-apply any transformations in caustaData.
transformer <- GetTransforms(caustaData)

# Now, create a new data.frame and apply the same transformation to it.  
# Any levels in the factor that are not "a", or "b" will be replaced 
# with "Other"
new.df <- data.frame(var__AP=c("a", "b", "c", "c", "c", "d", "a", NA))
transformed.df <- transformer(new.df)
transformed.df$var__AP

Causata documentation built on May 2, 2019, 3:26 a.m.