trans_composition {mtb} | R Documentation |
Transformation for continuous data with a finite number of distinct values
Description
trans_composition()
derives a transformation from a numerical vector with a smaller number (ideally < 30) of distinct values.
The return can be used with function ggplot::scale_x_continuous()
or ggplot::scale_y_continuous()
to create a desired axis.
Usage
trans_composition(x = NULL, nb = 30, brk = NA, dab = NA, dgrd = NA, dgrd2 = NA)
Arguments
x |
A numerical vector used in a plot as (typically) |
nb |
An integer for the maximum number of breaks. Default=30 |
brk |
One of
|
dab |
One of
|
dgrd |
One of
|
dgrd2 |
One of
|
Value
A transformation function
Examples
library(ggplot2)
pdt=data.frame(x=rep(c(0.5, 1, 10,11,12, 100, 1000), each=5))
pdt$y=pdt$x+rnorm(length(pdt$x))
t=trans_composition(pdt$x,brk=50, dab=3)
ggplot(pdt, aes(x=x, y=y))+geom_point()+scale_x_continuous(trans=t)