TxpSlice-class {toxpiR} | R Documentation |
ToxPi Slice
Description
S4 class to store ToxPi slices
Usage
TxpSlice(txpValueNames, txpTransFuncs = NULL)
## S4 method for signature 'TxpSlice'
txpValueNames(x)
## S4 replacement method for signature 'TxpSlice'
txpValueNames(x) <- value
## S4 method for signature 'TxpSlice'
txpTransFuncs(x)
## S4 replacement method for signature 'TxpSlice'
txpTransFuncs(x) <- value
## S4 method for signature 'TxpSlice'
length(x)
## S4 method for signature 'TxpSlice,TxpSlice'
merge(x, y)
Arguments
txpValueNames |
Passed to |
txpTransFuncs |
Passed to |
x , y |
|
value |
Replacement value |
Details
If the user supplies txpTransFuncs
a single function/TxpTransFunc object,
the given function will be recycled for each input with a warning.
Functions
-
txpValueNames,TxpSlice-method
: ReturntxpValueNames
slot -
txpTransFuncs,TxpSlice-method
: ReturntxpTransFuncs
slot -
length,TxpSlice-method
: Return number of inputs in slice; shortcut forlength(txpValueNames(x))
-
merge,TxpSlice,TxpSlice-method
: Merge twoTxpSlice
objects into a single slice
Slots
txpValueNames
vector(<character>)
specifying the input columns to include in the slicetxpTransFuncs
TxpTransFuncList with one function per entry in
txpValueNames
or an object that can be coerced toTxpTransFuncList
; whenNULL
, no transformation function applied
Examples
## Create TxpSlice object
# Without transform functions
TxpSlice(txpValueNames = c("sqrData", "expData"))
# With transform functions
TxpSlice(txpValueNames = c("sqrData", "expData"),
txpTransFuncs = c(sq = function(x) x^2, log = function(x) log(x)))
# Transformation function recycled with warning when single function given
TxpSlice(txpValueNames = c("sqrData", "expData"),
txpTransFuncs = function(x) x^2)
## Access TxpSlice slots
sl <- TxpSlice(txpValueNames = c("sqrData", "expData"),
txpTransFuncs = c(sq = function(x) x^2,
log = function(x) log(x)))
txpValueNames(sl)
txpTransFuncs(sl)
## Replacement
txpValueNames(sl)[1] <- "hello"
sl
txpTransFuncs(sl)[[2]](exp(1))
txpTransFuncs(sl)[[2]] <- function(x) sqrt(x)
txpTransFuncs(sl)[[2]](exp(1))
# Note that replacing a single list element does NOT update the name
sl
names(txpTransFuncs(sl))[2] <- "sqrt"
sl
# Replacing the whole list DOES update the names
txpTransFuncs(sl) <- list(sqrt = function(x) sqrt(x),
log = function(x) log(x))
sl
## length -- returns number of inputs
length(TxpSlice(letters))
## merge
s1 <- TxpSlice("hello")
s2 <- TxpSlice("data")
merge(s1, s2)
# Note, input names still must be unique
## Not run: merge(s1, s1) ## produces error