dQuote
Quote Text

### Description

Add double or single quotation marks to the start and end of an object.

### Usage

    dQuote(x, q = getOption("useFancyQuotes"))
    sQuote(x, q = getOption("useFancyQuotes"))

### Arguments

x | any object.
q | One of TRUE, FALSE, NULL, "UTF-8", "TeX", or a vector of four character strings. This overrides the value of getOption("useFancyQuotes"), which is described below.

### Details

These functions coerce the argument x to a character vector. Then dQuote adds double quotation marks, and sQuote adds single quotation marks, around each element of the character vector.
These functions are designed to allow you to quote text that can then be used on output.
These functions do not encode the tab, new line, and other special characters. For more information, see encodeString.
The characters used for double or single quotation marks are controlled by the option useFancyQuotes.

- If this option is NULL or FALSE, then undirectional ASCII quotation marks are used. These are ASCII code 0x22 for double quotation mark, and ASCII code 0x27 for single quotation mark.
- If this option is the string "UTF-8", then directional Unicode quotation marks are used. These are Unicode U+201C and U+201D for left and right double quotation marks, and U+2018 and U+2019 for left and right single quotation marks.
- If this option is the string "TeX", then Tex style quotation marks are used. These are single grave accent (ASCII code 0x60) and single apostrophe (ASCII code 0x27) for the left and right single quotation marks, and doubled grave accent and doubled apostrophe for the left and right double quotation marks.
- If this option is a character vector of length four, then the first two elements are used as the left and right single quotation marks, and the third and fourth elements are used as the left and right double quotation marks.

By default, the option useFancyQuotes is TRUE, which means to use directional Unicode quotation marks (as if the option was "UTF-8") if these characters can be represented in the current locale encoding. If these characters cannot be represented, undirectional ASCII quotation marks are used (as if useFancyQuotes was FALSE).
If this option is anything other than the values described above, undirectional ASCII quotation marks are used (as if useFancyQuotes was FALSE).
Value
returns a character vector where each element is a character string enclosed in either single or double quotation marks.
Differences between Spotfire Enterprise Runtime for R and Open-source R
Currently, in Spotfire Enterprise Runtime for R, if the option useFancyQuotes is TRUE, directional Unicode quotation marks are used, whether or not these characters are supported by the current locale encoding.
References
Kuhn, M. ASCII and Unicode quotation marks. http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html.
See Also
encodeString, options, paste, stop.
Examples

    # typical use: adding quotes within a message
    message("The argument ", dQuote("names"), " must be a character vector.")
    # put quotes around each element of a vector
    cat("letters: ", dQuote(LETTERS[1:5]), "\n")
    # letters:  "A" "B" "C" "D" "E"
    # ASCII undirectional quotation marks
    origFancyQuotes <- options(useFancyQuotes = FALSE)
    charToRaw(dQuote('a'))
    # [1] 22 61 22
    charToRaw(sQuote('a'))
    # [1] 27 61 27
    # Default setting: directional Unicode quotation marks
    options(useFancyQuotes = TRUE)
    charToRaw(dQuote('a'))
    # [1] e2 80 9c 61 e2 80 9d
    charToRaw(sQuote('a'))
    # [1] e2 80 98 61 e2 80 99
    # Tex style quotation marks
    options(useFancyQuotes = "TeX")
    charToRaw(dQuote('a'))
    # [1] 60 60 61 27 27
    charToRaw(sQuote('a'))
    # [1] 60 61 27
    # Unicode directional quotation marks
    options(useFancyQuotes = "UTF-8")
    charToRaw(dQuote('a'))
    # [1] e2 80 9c 61 e2 80 9d
    charToRaw(sQuote('a'))
    # [1] e2 80 98 61 e2 80 99
    # user-defined quotation marks
    options(useFancyQuotes = c("<", ">", "<<", ">>"))
    dQuote('a')
    sQuote('a')
    # override options("useFancyQuotes")
    dQuote('a', q = c("[", "]", "[[", "]]"))
    sQuote('a', q = c("[", "]", "[[", "]]"))
    options(origFancyQuotes)

Package base version 6.1.5-18
Package Index