Learn R Programming

JATSdecoder (version 1.2.0)

which.term: which.term

Description

Returns search element/s from vector that is/are present in text or returns search term hit vector for all terms.

Usage

which.term(x, terms, tolower = TRUE, hits_only = FALSE)

Value

Binary hit vector with search term named elements if hits_only=FALSE.

Character vector with identified search term elements if hits_only=TRUE.

Arguments

x

text string to process.

terms

search term vector.

tolower

Logical. If TRUE converts search terms and text to lower case.

hits_only

Logical. If TRUE returns search pattern/s, that were found in text and not a search term hit vector.

Examples

Run this code
text<-c("This demo demonstrates how which.term works.",
       "The result is a simple 0, 1 coded vector for all search patterns or 
        a vector including the identified patterns only.")
which.term(text,c("Demo","example","work"))
which.term(text,c("Demo","example","work"),tolower=TRUE,hits_only=TRUE)

Run the code above in your browser using DataLab