The rep_len()
function in R returns the desired length of a vector object's replicated values.
The rep_len()
function takes the following syntax:
rep_len(x, length.out)
The rep_len()
function takes the following parameter values:
x
: This is the vector object to be replicated.length.out
: This is the desired length of the replicate object or the output vector.The rep_len()
function returns an object type that is the same as the input vector, x
.
# A code to illustrate the rep_len() function# creating an input vectora <- 1:5# creating a replicate of length 10replica <- rep_len(a, 10)# printing the replicatereplica
a
.a
with the desired length of 10
. We assign the result to a variable, replica
.replica
.