The function rep is a widely used function to replicate elements of vectors and lists. rep
replicates the values in x
. It is a generic function, and the (internal) default method is described here.
The basic usage of rep
function is written in the exercise.
# Using c function to combine two vectors
rep(1:4, 2)
# Argument each
rep(1:4, each = 2)
# Argument each and time
rep(1:4, each = 2, times = 3)
# Argument each, len
rep(1:4, each = 2, len = 10)