Learn R Programming

transforEmotion (version 0.1.5)

punctuate: Punctuation Removal for Text

Description

Keeps the punctuations you want and removes the punctuations you don't

Usage

punctuate(
  text,
  allowPunctuations = c("-", "?", "'", "\"", ";", ",", ".", "!")
)

Value

Returns text with only the allowed punctuations

Arguments

text

Character vector or list. Text in a vector or list data format

allowPunctuations

Character vector. Punctuations that should be allowed in the text. Defaults to common punctuations in English text

Author

Alexander P. Christensen <alexpaulchristensen@gmail.com>

Details

Coarsely removes punctuations from text. Keeps general punctuations that are used in most English language text. Apostrophes are much trickier. For example, not allowing "'" will remove apostrophes from contractions like "can't" becoming "cant"

Examples

Run this code
# Load data
data(neo_ipip_extraversion)

# Example text 
text <- neo_ipip_extraversion$friendliness

# Keep only periods
punctuate(text, allowPunctuations = c("."))

Run the code above in your browser using DataLab