strs_count counts the number of times a specified substring occurs in eachelement of a character vector. Optionally, the search can be limited to asubstring of each element, specified bystart andend positions. Thisfunction is similar to Python'sstr.count() method.
Arguments
- string
A character vector where each element is a string in which tocount occurrences of
substring.- substring
The substring to count within each element of
string.- start
An optional integer specifying the starting position in eachelement of
stringfor the search. Defaults to 1, indicating the start ofthe string.- end
An optional integer specifying the ending position in each elementof
stringfor the search. The default value of -1 indicates the end of thestring.
Value
An integer vector of the same length asstring, with each elementindicating the count ofsubstring in the corresponding element ofstring.