This function recycles all supplied elments to the maximal dimension.

Recycle(...)

Arguments

...

a number of vectors of elements.

Value

a list of the supplied elements
attr(,"maxdim") contains the maximal dimension of the recyled list

Author

Andri Signorell <andri@signorell.net>

See also

Examples

Recycle(x=1:5, y=1, s=letters[1:2])
#> $x
#> [1] 1 2 3 4 5
#> 
#> $y
#> [1] 1 1 1 1 1
#> 
#> $s
#> [1] "a" "b" "a" "b" "a"
#> 
#> attr(,"maxdim")
#> [1] 5

z <- Recycle(x=letters[1:5], n=2:3, sep=c("-"," "))
sapply(1:attr(z, "maxdim"), function(i) paste(rep(z$x[i], times=z$n[i]), collapse=z$sep[i]))
#> [1] "a-a"   "b b b" "c-c"   "d d d" "e-e"