applyXPtr {rrp} | R Documentation |
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
.
applyXPtr(d, idx, sub, f)
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 |
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)
.
val |
an invisible object of type list |
S.M. Iacus
Iacus, S.M., Porro, G. (2009) Random Recursive Partitioning: a matching method for the estimation of the average treatment effect, Journal of Applied Econometrics, 24, 163-185.
Iacus, S.M., Porro, G. (2007) Missing data imputation, matching and other applications of random recursive partitioning, Computational Statistics and Data Analysis, 52, 2, 773-789.
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