bindList: Joins elements of a list according to some criteria.

Description Usage Arguments Details See Also Examples

View source: R/utils.R

Description

This function is a flexible version of rbind, cbind c. Its binds together every elements

Usage

1
2
3
bindList(lst, bindfun = rbind, fun = NULL, recursive = 0)

bindArgs(..., bindfun = rbind, fun = NULL, recursive = 0)

Arguments

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 bindArgs.

Details

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.

See Also

rbind cbind c lapply

Examples

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)

tunelipt/wutils documentation built on Nov. 5, 2019, 11:01 a.m.