recycle | R Documentation |
recycle vector to given length
recycle(vec, length, na.fill = FALSE)
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) |
vector
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.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.