Description Usage Arguments Value Author(s) Examples
Effectively a version of rep
, where only once value can be
repeated (by default, a space; " "), but it can be repeated a variable number
of times. Useful for creating even spacing for print and summary methods.
1 | rep_char(x = " ", times)
|
x |
A value to repeat. Will be coerced to |
times |
A |
A character
vector
of x repated various
times
Brendan Rocks rocks.brendan@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Strings repeating 'a' a variable number of times!
rep_char("a", 1:5)
# Slightly more useful. Some text strings which we'd like to present:
desc <- c("\n", "first : 1st\n", "second : 2nd\n", "third : 3rd\n",
"fourth : 4th\n", "umpteenth : ...\n")
# However, the varying lengths make them look a little awkward
cat(desc)
# We can use rep_char to add extra spaces to the strings which are shorter
# than the longest
desc_spaced <- paste0(rep_char(times = max(nchar(desc)) - nchar(desc)), desc)
# Much better
cat(desc_spaced)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.