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. 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 TIBCO Enterprise Runtime for R and Open-source R
Currently, in TIBCO 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.0.0-69
Package Index