Description Usage Arguments Examples
Extract and replace all subsequences from a bstr sequences
1 2 3 4 5 6 7 | bstr_sub_all(bstrobj, from = list(1L), to = list(-1L), length)
bstr_sub_all(bstrobj, from = list(1L), to = list(-1L), length, omit_na = FALSE) <- value
bstr_sub_replace_all(..., replacement, value = replacement)
bstr_sub_all_replace(..., replacement, value = replacement)
|
bstrobj |
bstr class object or character vector |
from |
a list of integer vectors giving the start indexes or a
list of two-column matrices, each of type |
to |
a list of integer vectors giving the end indexes |
length |
a list of integer vectors giving the substring lengths |
omit_na |
a single logical value; indicates whether missing values
in any of the indexes or in |
value |
a list of character vectors defining the replacement strings [replacement function only] |
... |
arguments to be passed to |
replacement |
alias of |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | (temp <- dstr_rand_seq(3, 20, "[AT]", seed = 1))
(pos_A_trails <- stringr::str_locate_all(temp, "A{2,}"))
# Extract all A trails
bstr_sub_all(temp, pos_A_trails)
# Substitute all A trails by x
bstr_sub_all(temp, pos_A_trails) <- "x"
temp
# Substitute all A trails by case switched ones
original <- change <- dstr_rand_seq(2, 10, "[AaT]", seed = 1)
pos_A_trails <- stringr::str_locate_all(change, "[Aa]{2,}")
switched_A_trails <-
bstr_sub_all(change, pos_A_trails) %>%
lapply(bstr_switch_case)
bstr_sub_all(change, pos_A_trails) <- switched_A_trails
c(original[1], change[1], original[2], change[2])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.