str_subset_ops {tinycodet} | R Documentation |
String Subsetting Operators
Description
String subsetting operators.
The x %sget% ss
operator
gets a certain number of the first and last characters of every string in
character vector x
.
%s><%
is an alias for %sget%
.
The x %strim% ss
operator
trims a certain number of the first and last characters of every string in
character vector x
.
%s<>%
is an alias for %strim%
.
Usage
x %sget% ss
x %strim% ss
x %s><% ss
x %s<>% ss
Arguments
x |
a character vector. |
ss |
a vector of length 2, or a matrix with 2 columns with |
Details
These operators serve as a way to provide straight-forward string sub-setting.
Value
The x %sget% ss
operator
gives a certain number of the first and last characters of
character vector x
.
The x %strim% ss
operator
removes a certain number of the first and last characters of
character vector x
.
See Also
Examples
x <- c(paste0(letters[1:13], collapse = ""),
paste0(letters[14:26], collapse = ""))
print(x)
ss <- c(2, 3)
x %sget% ss
x <- c(paste0(letters[1:13], collapse = ""),
paste0(letters[14:26], collapse = ""))
print(x)
ss <- c(1, 0)
x %sget% ss
x <- c(paste0(letters[1:13], collapse = ""),
paste0(letters[14:26], collapse = ""))
print(x)
ss <- c(2, 3)
x %strim% ss
x <- c(paste0(letters[1:13], collapse = ""),
paste0(letters[14:26], collapse = ""))
print(x)
ss <- c(1, 0)
x %strim% ss