transformif | R Documentation |
Transforms x
if cond
is TRUE
by \log(a+b*x)
if p==0
and (a+b*x)^p)
.
Otherwise the transformation can be either applied to each element of x
, or to all elements of x
.
transformif(x, cond, a = -abs(min(x)), b = 1, p = 1)
x |
vector: values |
cond |
logical: condition if transformation should be applied |
a |
numeric: shift (default: |
b |
numeric: scale (default: |
p |
numeric: power (default: |
A transformed vector
x <- rnorm(5)
transformif(x, min(x)<0) # all transformed elements > 0
transformif(x, x<0) # only negative elements are transformed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.