strs_count
counts the number of times a specified substring occurs in each
element of a character vector. Optionally, the search can be limited to a
substring of each element, specified by start
and end
positions. This
function is similar to Python's str.count()
method.
Arguments
- string
A character vector where each element is a string in which to count occurrences of
substring
.- substring
The substring to count within each element of
string
.- start
An optional integer specifying the starting position in each element of
string
for the search. Defaults to 1, indicating the start of the string.- end
An optional integer specifying the ending position in each element of
string
for the search. The default value of -1 indicates the end of the string.
Value
An integer vector of the same length as string
, with each element
indicating the count of substring
in the corresponding element of string
.