applyXPtr {rrp}R Documentation

Apply facility for objects of class XPtr

Description

This tool function allow to apply a function along some index and on a subset of elements of the XPtr object. Is the counterpart of apply for objects fo class matrix.

Usage

applyXPtr(d, idx, sub, f)

Arguments

d an object of class XPtr
idx a vector of integers, the indexes of the apply
sub a vector of integers, the indexes of the subest
f a function to be evaluated in the .GlobalEnv

Details

The object d is like a dist object, which is one-dimensional but usually associated to a symmetrix matrix M with 0's on the diagonal. This function allows to apply a function f on d as if it was applied this way on the matrix M: apply(M[idx,sub],1,f).

Value

val an invisible object of type list

Author(s)

S.M. Iacus

References

Iacus, S.M., Porro, G. (2006) Random Recursive Partitioning and its applications to missing data imputation, classification and average treatment effect estimation, submitted.

See Also

newXPtr

Examples

a <- newXPtr(10,1)
addXPtr(a, list(c(1,3,4,9), c(2,5), c(1,7,9)), c(-1, 5, 10))
f <- function(x) sum(x)
idx <- 1:5
sub <- 7:10
applyXPtr(a, idx, sub, f) -> l
(XPtrToDist(a))
l

[Package rrp version 2.7 Index]