get_transform: Transform a numeric vector

View source: R/normality.R

get_transformR Documentation

Transform a numeric vector

Description

The get_transform() gets transformation of numeric variable.

Usage

get_transform(
  x,
  method = c("log", "sqrt", "log+1", "log+a", "1/x", "x^2", "x^3", "Box-Cox",
    "Yeo-Johnson")
)

Arguments

x

numeric. numeric for transform

method

character. transformation method of numeric variable

Details

The supported transformation method is follow.:

  • "log" : log transformation. log(x)

  • "log+1" : log transformation. log(x + 1). Used for values that contain 0.

  • "log+a" : log transformation. log(x + 1 - min(x)). Used for values that contain 0.

  • "sqrt" : square root transformation.

  • "1/x" : 1 / x transformation

  • "x^2" : x square transformation

  • "x^3" : x^3 square transformation

  • "Box-Cox" : Box-Box transformation

  • "Yeo-Johnson" : Yeo-Johnson transformation

Value

numeric. transformed numeric vector.

See Also

plot_normality.

Examples

## Not run: 
# log+a transform 
get_transform(iris$Sepal.Length, "log+a")

if (requireNamespace("forecast", quietly = TRUE)) {
  # Box-Cox transform 
  get_transform(iris$Sepal.Length, "Box-Cox")

  # Yeo-Johnson transform 
  get_transform(iris$Sepal.Length, "Yeo-Johnson")
} else {
  cat("If you want to use this feature, you need to install the forecast package.\n")
}

## End(Not run)


dlookr documentation built on July 9, 2023, 6:31 p.m.