keepWords | R Documentation |
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.
strsplit()
keepWords(loremIpsum(), 1:3) keepWords(c(loremIpsum(),'Another character string!'), slc = c(1,4)) keepWords(c(loremIpsum(),'A second character string.'), slc = c(1,4), na.rm = TRUE, collapse = '/') strex <- c('Lorem ipsum', 'dolor sit', ' amet;') keepLetters(strex, c(1,4)) keepLetters(strex, c(1,4), collapse = "") keepInitials("National Basketball Association") wordCount(c("two words!", "... and three words")) wordCount(loremIpsum())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.