[R] Interleaving elements of two vectors?
Rolf Turner
r.turner at auckland.ac.nz
Thu Mar 25 23:17:23 CET 2010
I think that
riffle <- function (a,b) {
n <- min(length(a),length(b))
p1 <- as.vector(rbind(a[1:n],b[1:n]))
p2 <- c(a[-(1:n)],b[-(1:n)])
c(p1,p2)
}
does the trick, and is pretty simple ....
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list