recycle: recycle vector to given length

Description Usage Arguments Value Note Examples

View source: R/utils.r

Description

recycle vector to given length

Usage

1
recycle(vec, length, na.fill = FALSE)

Arguments

vec

vector to be recycled

length

integer or vector. integer determines length of recycling. If a vector is provided the length of the vector is used.

na.fill

Use NAs for filling up to given length (default=FALSE)

Value

vector

Note

If 2nd argument is a vector, the first argument is recycled to the length of the second vector. Instead of recycling the vector can also be added extra NAs if the length argument is smaller than the number of elements from vec, vec is cut off to make it usable for many purposes.

Examples

1
2
3
4
5
6
7
recycle(c(1,2,3), 7)
recycle(c(1,2,3), letters[1:7])
recycle(c(1,2,3), 7, na.fill=TRUE)
recycle(1, letters[1:3], na.fill=TRUE)
recycle(letters[1:3], 7)
recycle(letters[1:3],  letters[1:7])
recycle(letters[1:40],  letters[1:7])		# vec is cut off

markheckmann/OpenRepGrid documentation built on April 30, 2021, 2:33 a.m.