# basic example
vect <- rnorm(100)
# make 50 replicates
repl <- rep(list(vect), 50)
repmatch(repl, FUN=mean, direct="dim")
# named input
# two vectors
# a
a<- 1:10
names(a) <- letters[1:length(a)]
a[c(3,5,8)] <- NA
a <- a[!is.na(a)]
#b
b<- 10:1
names(b) <- letters[length(b):1]
b[c(1, 3,6, length(b))]<- NA
b <- b[!is.na(b)]
# list
x2 <- rep(c(list(a),list(b)), 3)
# simple match - falling through "dim" to "name" directive
repmatch(x2, FUN=NULL)
# prototyped
prot <- 1:10
names(prot) <-letters[1:10]
repmatch(x2, FUN=mean, proto=prot, na.rm=TRUE)
Run the code above in your browser using DataLab