Skip to contents

Extension of S4Vectors::SimpleList that requires uniquely-named elements and holds only TxpSlice objects.

Usage

TxpSliceList(...)

# S4 method for TxpSliceList
txpValueNames(x, simplify = FALSE)

# S4 method for TxpSliceList
txpTransFuncs(x, simplify = FALSE)

# S4 method for TxpSliceList
duplicated(x)

as.TxpSliceList(x)

Arguments

...

TxpSlice object to create TxpSliceList object; MUST give unique names to each slice

x

TxpSliceList object

simplify

Scalar logical, when TRUE the returned list is simplified to a vector/TxpTransFuncList object

Details

Note, there is no coercion for TxpSlice to TxpSliceList because unique names are required.

Functions

  • txpValueNames,TxpSliceList-method: Return list of txpValueNames slots for the contained TxpSlice objects, or vector when simplify = TRUE

  • txpTransFuncs,TxpSliceList-method: Return list of txpTransFuncs slots for the contained TxpSlice objects, or TxpTransFuncList when simplify = TRUE

  • duplicated,TxpSliceList-method: Returns logical vector of length(x), where TRUE indicates a duplicate slice in the list; see base::duplicated

Examples

## Create TxpSlice objects
s1 <- TxpSlice("input1", list(linear = function(x) x))
s2 <- TxpSlice(c("input2", "input3"), 
               list(log = function(x) log(x), sqrt = function(x) sqrt(x)))

## Create TxpSliceList
sl <- TxpSliceList(s1 = s1, s2 = s2)

## Accessors
txpValueNames(sl)
#> $s1
#> [1] "input1"
#> 
#> $s2
#> [1] "input2" "input3"
#> 
txpValueNames(sl, simplify = TRUE)
#>       s1      s21      s22 
#> "input1" "input2" "input3" 

txpTransFuncs(sl)
#> $s1
#>   TxpTransFuncList of length 1: linear
#> 
#> $s2
#>   TxpTransFuncList of length 2: log sqrt
#> 
txpTransFuncs(sl, simplify = TRUE)
#>   TxpTransFuncList of length 3: linear log sqrt

## Coercion
as(list(s1 = TxpSlice("hello"), s2 = TxpSlice("user")), "TxpSliceList")
#> TxpSliceList of length 2
#> names(2): s1 s2
as.TxpSliceList(c(s1 = TxpSlice("hello"), s2 = TxpSlice("user")))
#> TxpSliceList of length 2
#> names(2): s1 s2

## Concatenation
c(sl, TxpSliceList(s3 = TxpSlice("input4")))
#> TxpSliceList of length 3
#> names(3): s1 s2 s3

## Reduce TxpSliceList to single slice
Reduce(merge, sl)
#> TxpSlice with 3 inputs.
#>   txpValueNames(3): input1 input2 input3
#>   txpTransFuncs(3): linear log sqrt