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 <- 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" |
vec_new <- rep(vec, each = 3) # Apply rep function vec_new # Printing new vector # "A" "A" "A" "B" "B" "B" "C" "C" "C"