str_sub_replace {stringr} | R Documentation |
str_sub<-
will recycle all arguments to be the same length as the
longest argument.Replace substrings in a character vector.
str_sub<-
will recycle all arguments to be the
same length as the longest argument.
str_sub(string, start = 1L, end = -1L) <- value
string |
input character vector. |
start |
integer vector giving position of first charater in substring, defaults to first character. If negative, counts backwards from last character. |
end |
integer vector giving position of last character in substring, defaults to last character. If negative, counts backwards from last character. |
value |
replacement string |
character vector of substring from start
to
end
(inclusive). Will be length of longest input
argument.
x <- "BBCDEF" str_sub(x, 1, 1) <- "A"; x str_sub(x, -1, -1) <- "K"; x str_sub(x, -2, -2) <- "GHIJ"; x str_sub(x, 2, -2) <- ""; x