replace_abbreviation: Replace Abbreviations

Description Usage Arguments Value See Also Examples

View source: R/replace_abbreviation.R

Description

This function replaces abbreviations with long form.

Usage

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

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.

Value

Returns a vector with abbreviations replaced.

See Also

bracketX, qprep, replace_contraction, replace_number, replace_symbol

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
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)

## End(Not run)

Example output

Loading required package: qdapDictionaries
Loading required package: qdapRegex
Loading required package: qdapTools
Loading required package: RColorBrewer
OpenJDK 64-Bit Server VM warning: Can't detect initial thread stack location - find_vma failed

Attaching package: 'qdap'

The following object is masked from 'package:base':

    Filter

[1] "Mister Jones is here at 7:30 PM."                    
[2] "Check it out at www dot github dot com /trinker/qdap"
[3] "ie He's a Senior Doctor ; the best in 2012 AD."      
[4] "the robot at t.s. is 10ft. 3in."                     
[1] "Mr. Jones is here at 7:30 p.m."             
[2] "Check it out at www.github.com/trinker/qdap"
[3] "i.e. He's a sr. dr.; the best in 2012 A.D." 
[4] "the robot at talkstats is 10 feet 3 inch."  
      abv       rep
1     Mr.    Mister
2    Mrs.    Misses
3     Ms.      Miss
4    .com   dot com
5    www.   www dot
6    i.e.        ie
7    A.D.        AD
8    B.C.        BC
9    A.M.        AM
10   P.M.        PM
11 et al.     et al
12    Jr.    Junior
13    Dr.    Doctor
14    Sr.    Senior
15    in.      inch
16    ft.      feet
17   t.s. talkstats
[1] "Mister Jones is here at 7:30 PM."                    
[2] "Check it out at www dot github dot com /trinker/qdap"
[3] "ie He's a Senior Doctor ; the best in 2012 AD."      
[4] "the robot at talkstats is 10 feet 3 inch."           
Warning message:
system call failed: Cannot allocate memory 

qdap documentation built on Nov. 20, 2017, 5:09 p.m.