Select words or letters based on their position in character strings.
keepWords( str, slc = 1, collapse = " ", na.rm = FALSE, split_words = "[[:punct:][:space:]]+" ) keepLetters( str, slc = 1, collapse = "", na.rm = FALSE, rm_punct = "[[:punct:][:space:]]+" ) keepInitials(str, split_words = "[\n\t\r\f\b[:punct:] ]+", collapse = "") wordCount(str, split_words = "[[:punct:][:space:]]+")
str | an input character vector (or a list) from which words will be extracted. |
---|---|
slc | a vector of integer indicating the selected positions of the words (or letters) to be kept. |
collapse | character string used to separate selected words (or
letters), if |
na.rm | a logical. Should missing values be removed? |
split_words | a character string containing a regular expression used to split words. |
rm_punct | a character string containing a regular expression used to remove punctuation characters. |
A vector (or a list) of the selected words.
keepLetters
: A vector (or a list) of the selected letters.
keepInitials
: A vector (or a list) of initials.
wordCount
: A vector of the number of words for every character
strings passed as an input.
#> [1] "Lorem ipsum dolor"#> [1] "Lorem sit" "Another NA"#> [1] "Lorem/sit" "A/string"#> [1] "Le" "do" "at"#> [1] "Le" "do" "at"keepInitials("National Basketball Association")#> [1] "NBA"#> [1] 2 3#> [1] 201