rep(): replicate elements of vectors and lists

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.

Instruction

  • Click the Submit button to see how rep function works.
# 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)

Previous: 1-11 | seq(): Sequence function

Next: 1-13 | sum(): Sum up values in a vector

Back to Main