TxpTransFunc-class {toxpiR} | R Documentation |
Numeric transformation function
Description
S4 class to store numeric transformation functions
Usage
TxpTransFunc(x)
Arguments
x |
function, see details |
Details
TxpTransFunc
inherits from a standard R function, but specifies a
single input and a numeric output of the same length.
Functions can be passed directly to TxpTransFuncList
list and the
functions will be coerced to TxpTransFunc
.
We have an imperfect system for dealing with primitive functions (e.g.,
base::sqrt).
To coerce primitives to TxpTransFunc's, we wrap them in another function
cal; wrapping the primitives obscures the original function and requires
the user to explore the function environment to understand the primitive
called.
We recommend wrapping primitives in separate functions to make the intent
clear, .e.g., mysqrt <- function(x) sqrt(x)
.
Examples
f1 <- function(x) "hello"
f2 <- function(x) 3
f3 <- function(x) x + 5
## Not run:
t1 <- TxpTransFunc(x = f1) ## Produces error
t2 <- TxpTransFunc(x = f2) ## Produces error
## End(Not run)
t3 <- TxpTransFunc(x = f3)
## TxpTransFunc objects act as any other function
body(t3)
formals(t3)
t3(1:10)
## Coercion from functions
## Not run:
TxpTransFuncList(f1, f2, f3) ## Produces error because f1, f3 not valid
## End(Not run)
[Package toxpiR version 1.2.1 Index]