| remove_space | R Documentation |
Remove and normalize spaces
remove_space(
x,
trim_start = TRUE,
trim_end = FALSE,
collapse_multiple = TRUE,
preserve_newlines = TRUE
)
x |
A vector of character strings. |
trim_start |
Whether to remove leading spaces before the first word.
Default is |
trim_end |
Whether to remove trailing spaces after the last word.
Default is |
collapse_multiple |
Whether to collapse multiple consecutive spaces between words into a single space.
Default is |
preserve_newlines |
Whether to preserve newline characters when collapsing spaces.
Default is |
A character vector with spaces normalized according to the specified parameters.
x <- c(
" hello world ",
" test case ",
"no space",
" multiple spaces "
)
remove_space(x)
remove_space(x, trim_start = FALSE)
remove_space(x, trim_end = TRUE)
remove_space(x, collapse_multiple = FALSE)
remove_space(
x,
trim_start = FALSE,
trim_end = FALSE,
collapse_multiple = FALSE
)
# with newlines
multiline <- c(
"hello\n\n world ",
" first \n second "
)
remove_space(multiline)
remove_space(multiline, preserve_newlines = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.