rep2 | R Documentation |
Repeat something with the ability to also collapse the output. The base 'rep("ha", 3)' function does not support arguments like 'collapse' or 'sep' like 'paste(...)'. 'rep2' closes this gap.
rep2(x, n, ...)
x |
The object to repeat |
n |
The amount how often the object should be repeated |
... |
Further arguments passed to 'paste' (see 'help("paste")' for more information). |
The result from 'paste(rep(x, n), sep = sep, collapse = collapse)'
## rep2 is the same like rep:
rep(x = "ha", 3)
#> "ha" "ha" "ha"
rep2(x = "ha", 3)
#> "ha" "ha" "ha"
## ... but you can also use the arguments from `paste`:
rep2(x = "ha", n = 3, collapse = "")
#> "hahaha"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.