getWord: Extract a Specific Word from a Text String or List of Text...

View source: R/utils.R

getWordR Documentation

Extract a Specific Word from a Text String or List of Text Strings

Description

This function takes a text string or a list of text strings and extracts a specific word based on its position, using a given pattern to split the text into words.

Usage

getWord(tosearch, item = 1, pattern = "\\W+")

Arguments

tosearch

The text string or list of text strings from which to extract the word.

item

The position of the word to extract (1-based index). Default is 1.

pattern

The pattern used to split the text string into words. Default is "\W+" (one or more non-word characters).

Value

A character string containing the extracted word if tosearch is a single string, or a list of extracted words if tosearch is a list of strings.

Examples

getWord("aaa  bb,cc.",3)
getWord("aaa-bb-cc",2,pattern="-")

Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.