apply_functions: Apply-type methods

Description Usage Arguments Details Value See Also Examples

Description

These functions are apply-type functions for ContactGroup objects.

Usage

1
2
cgApply(cg, FUN, mc.cores=1, ...)
cgBandApply(cg, FUN, nbands=NULL, mc.cores=1, bstart=2, ...)

Arguments

cg

A ContactGroup object.

FUN

A function to be applied. For cgApply this function should operate on a square matrix. For cgBandApply this function should operate on a band, ie. a vector (see band).

mc.cores

The number of cores to be used. Defaults to 1

bstart

The first band to apply a function to. Defaults to 2. Only applicable to cgBandApply.

nbands

The last band to apply a function to. Default is nrow(cg) - 1. Only applicable to cgBandApply.

...

Passed to mclapply.

Details

These methods make it easy to apply functions to either all contact matrices or a set of bands in all contact matrices. Both methods accept a function FUN. For cgApply, the first argument should be cg, the contact group itself. For cgBandApply, the first argument should also be cg, and the second argument should be a specific band number. Additionally, the bands to be iterated are specified through bstart:nbands: bstart indicates the starting band, and nbands indicates the last band.

Value

For cgApply, a ContactGroup object. For cgBandApply, a list whose elements are the returned value of FUN.

See Also

ContactGroup, getBandMatrix, band

Examples

1
2
3
data(cgEx)
cgEx.1 <- cgApply(cgEx, FUN=function(xx){ xx + 1 })
band.matrix.list <- cgBandApply(cgEx, FUN=getBandMatrix, bstart=2, nbands=5)

bnbc documentation built on Nov. 8, 2020, 8:15 p.m.