transform: Data Transformations

Description Usage Arguments Details Value See Also Examples

Description

Performs variable transformation for standardization and resolving skewness of numerical variables.

Usage

1
2
3
4
5
transform(
  x,
  method = c("zscore", "minmax", "log", "log+1", "sqrt", "1/x", "x^2", "x^3",
    "Box-Cox", "Yeo-Johnson")
)

Arguments

x

numeric vector for transformation.

method

method of transformations.

Details

transform() creates an transform class. The transform class includes original data, transformed data, and method of transformation.

See vignette("transformation") for an introduction to these concepts.

Value

An object of transform class. Attributes of transform class is as follows.

See Also

summary.transform, plot.transform.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Standardization ------------------------------
creatinine_minmax <- transform(heartfailure$creatinine, method = "minmax")
creatinine_minmax
summary(creatinine_minmax)
plot(creatinine_minmax)

# Resolving Skewness  --------------------------
creatinine_log <- transform(heartfailure$creatinine, method = "log")
creatinine_log
summary(creatinine_log)

# plot(creatinine_log)

# plot(creatinine_log, typographic = FALSE)

# Using dplyr ----------------------------------
library(dplyr)

heartfailure %>%
  mutate(creatinine_log = transform(creatinine, method = "log+1")) %>%
  lm(sodium ~ creatinine_log, data = .)
  

bit2r/kodlookr documentation built on Dec. 19, 2021, 9:49 a.m.