Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR R

cbind vectors of different lengths r

bind.pad <- function(l, side="r", len=max(sapply(l,length)))
{
  if (side %in% c("b", "r")) {
    out <- sapply(l, 'length<-', value=len)
  } else {
    out <- sapply(sapply(sapply(l, rev), 'length<-', value=len, simplify=F), rev)}
  if (side %in% c("r", "l")) out <- t(out)
  out
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cbind #vectors #lengths
ADD COMMENT
Topic
Name
7+8 =