Learn R Programming

qdap (version 2.4.6)

replace_abbreviation: Replace Abbreviations

Description

This function replaces abbreviations with long form.

Usage

replace_abbreviation(
  text.var,
  abbreviation = qdapDictionaries::abbreviations,
  replace = NULL,
  ignore.case = TRUE
)

Value

Returns a vector with abbreviations replaced.

Arguments

text.var

The text variable.

abbreviation

A two column key of abbreviations (column 1) and long form replacements (column 2) or a vector of abbreviations. Default is to use qdapDictionaries's abbreviations data set.

replace

A vector of long form replacements if a data frame is not supplied to the abbreviation argument.

ignore.case

logical. If TRUE replaces without regard to capitalization.

See Also

bracketX, qprep, replace_contraction, replace_number, replace_symbol

Examples

Run this code
if (FALSE) {
x <- c("Mr. Jones is here at 7:30 p.m.",  
    "Check it out at www.github.com/trinker/qdap",
    "i.e. He's a sr. dr.; the best in 2012 A.D.",
    "the robot at t.s. is 10ft. 3in.")

replace_abbreviation(x)

#create abbreviation and replacement vectors
abv <- c("in.", "ft.", "t.s.")
repl <- c("inch", "feet", "talkstats")

replace_abbreviation(x, abv, repl)

(KEY <- rbind(abbreviations, data.frame(abv = abv, rep = repl)))
replace_abbreviation(x, KEY)
}

Run the code above in your browser using DataLab