count_when: Count if matching a string or regular expresion

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function allows the ability to count the occurences of a regular expresion or substring in a vector.

Usage

1

Arguments

vector

The vector to count the occurances in

value

The string or regular expression to test each vector against

Details

count_when passes the values through string_detect, so you can pass value through regex

Value

The count of ocurrences in vector

Author(s)

zekrom_vale

See Also

count_when for using str_detect to test a vector

count_if for using conditions to test a vector

count_if for counting using a dataframe or tibble, this has access to all columns

regex

str_detect

Examples

1
2
count_when(c("1","2","b","c","Z"), "\w")
# Returns 3, counting the ones with letters

zekrom-vale/zUtil.R documentation built on June 2, 2019, 10:57 p.m.