transformif: transformif

View source: R/transformif.R

transformifR Documentation

transformif

Description

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.

Usage

transformif(x, cond, a = -abs(min(x)), b = 1, p = 1)

Arguments

x

vector: values

cond

logical: condition if transformation should be applied

a

numeric: shift (default: -abs(min(x)))

b

numeric: scale (default: 1))

p

numeric: power (default: 1))

Value

transformed vector

Examples

x <- rnorm(5)
transformif(x, min(x)<0)  # all transformed elements > 0
transformif(x, x<0)       # only negative elements are transformed

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.