count | R Documentation |
count how often a certain string occurs, summing over a vector
count(pattern, x, ...)
x |
charstring (vector) |
... |
Further arguments passed to |
a |
character string (can have regex) |
single integer
Berry Boessenkool, berry-b@gmx.de, Jan 2025
vec210 <- c("with abc + abc + ab", "also abcde", "no alphabet")
vec021 <- c("no alphabet", "this has abcabc + ab", "also abcde")
vec000 <- c("this has no", "alphabet", "at all")
vec4 <- "this has abc and abcabcabc"
stopifnot(count("abc", vec210) == 3)
stopifnot(count("abc", vec021) == 3)
stopifnot(count("abc", vec000) == 0)
stopifnot(count("abc", vec4 ) == 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.