power_trans: Create a power transformation object

Description Usage Arguments Value Examples

View source: R/trans.R

Description

This function can be used to create a proper trans object that encapsulates a power transformation (x^n).

Usage

1

Arguments

n

The degree of the power transformation

Value

A trans object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Power of 5 transformations
trans <- power_trans(2)
trans$transform(1:10)

# Cubic root transformation
trans <- power_trans(1 / 3)
trans$transform(1:10)

# Use it in a plot
ggplot() +
  geom_line(aes(x = 1:10, y = 1:10)) +
  scale_x_continuous(trans = power_trans(2),
                     expand = c(0, 1))

Example output

Loading required package: ggplot2
 [1]   1   4   9  16  25  36  49  64  81 100
 [1] 1.000000 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.000000
 [9] 2.080084 2.154435

ggforce documentation built on March 5, 2021, 5:09 p.m.