Description Usage Arguments Details See Also Examples
This function is a flexible version of rbind, cbind c. Its binds together every elements
1 2 3 |
lst |
List whose elements shoud be binded. |
bindfun |
Bind function that should be used to join the elements. |
fun |
Function to be applied to each element of the list. |
recursive |
How many levels of recursrion should be used. |
... |
Arguments to be binded in |
Often it is necessary to join elements of a list according to some criteria.
This function does that in a very flexible way. The binding function can be specified,
and a function can be applied to each element before binding. Another feature
is the possibility to do this recursively. The function bindArgs
does
basically the same thing, except that it binds the variable list arguments instead of
the elements of a list.
1 2 3 4 5 6 7 8 | x <- matrix(rnorm(12), nr=3, nc=4)
lst <- lapply(1:4, function(i) x[,i])
print(bindList(lst, cbind) - x)
print(bindList(lst, rbind) - t(x))
print(bindList(lst, c, mean))
lst2 <- list(lst, lst, lst)
print(bindList(lst2, rbind, mean, recursive=1))
print(bindArgs(lst[[1]], lst[[2]], lst[[3]], lst[[4]], bindfun=cbind) - x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.