stringi (version 0.2-5)

stri_count_fixed: Count the Number of Fixed Pattern Matches

Description

This function counts the number of occurrences of a fixed pattern in a string.

Usage

stri_count_fixed(str, pattern)

Arguments

str
character vector
pattern
character vector

Value

  • Returns an integer vector with the number of matches.

Details

Vectorized over str and pattern.

If pattern is empty, then the result is NA and a warning is generated.

For natural language processing this function may be not give you desired results. Refer to stringi-search-fixed for more details.

See Also

Other search_count: stri_count_charclass; stri_count_coll; stri_count_regex; stri_count; stringi-search

Other search_fixed: stri_detect_fixed; stri_locate_all_fixed, stri_locate_first_fixed, stri_locate_first_fixed, stri_locate_last_fixed, stri_locate_last_fixed; stri_replace_all_fixed, stri_replace_first_fixed, stri_replace_first_fixed, stri_replace_last_fixed, stri_replace_last_fixed; stri_split_fixed; stringi-search-fixed; stringi-search

Examples

Run this code
s <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit."

if (stri_install_check(silent=TRUE))
stri_count_fixed(s, "")

if (stri_install_check(silent=TRUE))
stri_count_fixed(s, "o")

if (stri_install_check(silent=TRUE))
stri_count_fixed(s, "it")

if (stri_install_check(silent=TRUE))
stri_count_fixed(s, letters)

if (stri_install_check(silent=TRUE))
stri_count_fixed("babab", "b")

if (stri_install_check(silent=TRUE))
stri_count_fixed(c("stringi", "123"), "string")

Run the code above in your browser using DataLab