How to Apply the rep() Function in R (3 Examples)
In this tutorial you’ll learn how to apply the rep function in the R programming language.
Example 1: Applying rep Function with times Argument
rep(1:5, times = 2) # times argument # 1 2 3 4 5 1 2 3 4 5 |
rep(1:5, times = 2) # times argument # 1 2 3 4 5 1 2 3 4 5
Example 2: Applying rep Function with each Argument
rep(1:5, each = 2) # each argument # 1 1 2 2 3 3 4 4 5 5 |
rep(1:5, each = 2) # each argument # 1 1 2 2 3 3 4 4 5 5
Example 3: Applying rep Function with len Argument
rep(1:5, len = 13) # len argument # 1 2 3 4 5 1 2 3 4 5 1 2 3 |
rep(1:5, len = 13) # len argument # 1 2 3 4 5 1 2 3 4 5 1 2 3