pad_c | R Documentation |
Joins one or more character vectors as in str_c
but
with the character strings in each vector padded to make them equal length.
The last vector is by default left unpadded but can optionally be padded too.
pad_c(..., pad_last = FALSE, sep = " ", collapse = NULL)
... |
One or more character vectors as for |
pad_last |
A logical specifying whether to pad the last vector in addition to the others or leave it without padding. |
sep |
The string separator between vector elements. |
collapse |
An optional character string used to combine input vectors into a single string. |
A single string constructed in a similar way as with
str_c
but where vectors are padded to a uniform
width. If collapse is NULL (the default) the returned value is a character
vector with length equal to the length of the first input vector. If
collapse is non-NULL, the returned value is a character vector of length 1.
str_c
vec1 <- c("Avocado:", "Blueberry:", "Coconut:", "Dill:") vec2 <- c(rep("fruit", 3), "herb") vec3 <- c("green", "purple", "brown", "green") pad_c(vec1, pad_last = TRUE) cat(pad_c(vec1, vec2, collapse = "\n"), "\n") cat(pad_c(vec1, vec2, vec3, collapse = "\n"), "\n") pad_c(vec1, vec3, sep = " ... ", collapse = "; ")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.