Learn R Programming

quanteda (version 0.9.9-50)

char_tolower: convert the case of character objects

Description

char_tolower and char_toupper are replacements for tolower and toupper based on the stringi package.

Usage

char_tolower(x, keep_acronyms = FALSE, ...)

char_toupper(x, ...)

Arguments

x
a tokens object
keep_acronyms
if TRUE, do not lowercase any all-uppercase words. Only applies to char_tolower.
...
additional arguments passed to stringi functions, (e.g. stri_trans_tolower), such as locale

Examples

Run this code
txt <- c(txt1 = "b A A", txt2 = "C C a b B")
char_tolower(txt) 
char_toupper(txt)

# with acronym preservation
txt2 <- c(text1 = "England and France are members of NATO and UNESCO", 
          text2 = "NASA sent a rocket into space.")
char_tolower(txt2)
char_tolower(txt2, keep_acronyms = TRUE)
char_toupper(txt2)

Run the code above in your browser using DataLab