string_chomp | R Documentation |
Remove (empty) characters from a string as inspired by Ruby.
string_chomp(s) string_chop(s) string_trim(s, which, whitespace) string_cut(s, which)
s |
A string (character) vector. |
which |
Denotes how to trim/cut a vector (both, left only, or right only). |
whitespace |
Denotes which whitespace characters to remove. |
As inspired by Ruby, string_chomp()
removes all whitespace characters in a string.
The function string_chop()
removes the last character from a string.
The function string_trim()
acts the same as trimws
but its source code is more readable (in my opinion!).
string_cut()
removes characters from either the left, right, or both ends of a string.
The synonym pattern of these functions are s_*()
and *()
(replace asterisks with upper, chomp, chop, and trim. s_cut()
is the only synonym for string_cut()
).
Character vector.
https://github.com/robertschnitman/stringops
string_chomp(rownames(mtcars)) string_chop(rownames(mtcars)) string_trim(" s ") string_cut("cut this please", which = 'both')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.