Search notes:

R function: rep

foo <- 1:5

foo_x3 <- rep(foo, 3)

foo_x3
#  [1] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

rep(foo, each=3)
#  [1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5

rep(c('foo', 'bar', 'baz'), c(2, 3, 1))
# [1] "foo" "foo" "bar" "bar" "bar" "baz"
Github repository about-r, path: /functions/rep/basic.R

Creating a string of n dashes

rep together with paste can be used to create dashed strings:
cat("Underlined text\n");
cat(paste(rep('-', 15), collapse=''))
cat("\n");
Github repository about-r, path: /functions/rep/dashes.R
Underlined text
---------------

See also

seq, rep_len
Index to (some) R functions

Index