str_detect_tag: str_detect_tag

Description Usage Arguments Value Note See Also Examples

View source: R/str_detect_tags.R

Description

Similar to stringr's str_detect except matches are determined by the tag matching, i.e. substring matches. In this instance tags are taken to mean unary bits of information (flags) delineated by a separator. It is often convenient to place these tag in a single text field – thus this function to see if they match.

Usage

1
str_detect_tag(string, tags, sep = ",", ignore_case = TRUE)

Arguments

string

character vector with each element containing zero or more tags separated by sep

tags

character; vector of one or more tags, can be PCRE

sep

character; single element (usually single character) separator between tags in string ( Default: ',' )

ignore_case

logical whether to ignore case during matching ( Default: TRUE)

Tags are matched using str_detect using Perl regular expressions. Leading and trailing whitespace are ignored.

Value

logical of the same length of score indicating whether the element of score contains ANY of the tags.

Note

allow for leading/trailing white space

See Also

str_detect

Examples

1
2
3
4
5
  string <- c( 'X', 'Y', 'Z', 'Y,Z' )
  tags <- list( 'X', '(y)' )

  str_detect_tag( string, tags )   # T, T, F, T
  str_detect_tag( string, tags, ignore_case=FALSE )  # T, F, F, F

decisionpatterns/stringr.tools documentation built on Nov. 4, 2019, 10:24 a.m.