string_counts: Counts Strings in Text

View source: R/string_counts.R

string_countsR Documentation

Counts Strings in Text

Description

This function counts occurrences of text within one or more phrases.

Usage

string_counts(strings, search_data, ignore.case = TRUE)

Arguments

strings

character vector; value(s) to find

search_data

character vector; phrase(s) where values may exist

ignore.case

logical; indicates if spelling case matters, defaulting to ‘TRUE’

Value

list with two elements; ‘cntByTotal’ contains total occurrences and ‘cntByData’ contains occurrences for each element in ‘search_data’

Examples

note1 <- "I am the very model of a modern major general
I've information vegetable, animal, and mineral
I know the kings of England, and I quote the fights historical
From marathon to Waterloo in order categorical;
I'm very well acquainted, too, with matters mathematical,
I understand equations both the simple and quadratical
About binomial theorem I'm teeming with a lot o' news,
With many cheerful facts about the square of the hypotenuse"
note2 <- "The quick brown fox jumps over the lazy dog"
string_counts(c('I','the','couth'), c(note1, note2))

medExtractR documentation built on June 7, 2022, 1:08 a.m.