R How to Repeat a Sequence of Values Multiple Times (Example Code)

In this R tutorial you’ll learn how to replicate a vector sequence many times.

Example: Apply each Argument within rep() Function

vec <- LETTERS[1:3]               # Creating vector
vec                               # Printing vector
# "A" "B" "C"
vec_new  <- rep(vec, each = 3)    # Apply rep function
vec_new                           # Printing new vector
# "A" "A" "A" "B" "B" "B" "C" "C" "C"

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top