Learn R Programming

OpenRepGrid (version 0.1.9)

recycle: recycle vector to given length

Description

recycle vector to given length

Usage

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

Examples

Run this code
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

Run the code above in your browser using DataLab