[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  Quotes: Quotes

##  Description

Descriptions of the various uses of quoting in  R  .

##  Arguments

##  Character constants

Single and double quotes delimit character constants. They can be used
interchangeably but double quotes are preferred (and character constants are
printed using double quotes), so single quotes are normally only used to
delimit character constants containing double quotes.

Backslash is used to start an escape sequence inside character constants.
Escaping a character not in the following table is an error.

Single quotes need to be escaped by backslash in single-quoted strings, and
double quotes in double-quoted strings.

\n  |  newline   
---|---  
\r  |  carriage return   
\t  |  tab   
\b  |  backspace   
\a  |  alert (bell)   
\f  |  form feed   
\v  |  vertical tab   
\\\  |  backslash  \   
\'  |  ASCII apostrophe  '   
\"  |  ASCII quotation mark  "   
\\`  |  ASCII grave accent (backtick)  `   
\nnn  |  character with given octal code (1, 2 or 3 digits)   
\xnn  |  character with given hex code (1 or 2 hex digits)   
\unnnn  |  Unicode character with given code (1--4 hex digits)   
\Unnnnnnnn  |  Unicode character with given code (1--8 hex digits)   
  
Alternative forms for the last two are  \u{nnnn}  and  \U{nnnnnnnn}  . All
except the Unicode escape sequences are also supported when reading character
strings by ` [ scan ](/link/scan?package=base&version=3.6.2) ` and ` [
read.table ](/link/read.table?package=base&version=3.6.2) ` if ` allowEscapes
= TRUE ` . Unicode escapes can be used to enter Unicode characters not in the
current locale's charset (when the string will be stored internally in UTF-8).

The parser does not allow the use of both octal/hex and Unicode escapes in a
single string.

These forms will also be used by ` [ print.default
](/link/print.default?package=base&version=3.6.2) ` when outputting non-
printable characters (including backslash).

Embedded nuls are not allowed in character strings, so using escapes (such as
\0  ) for a nul will result in the string being truncated at that point
(usually with a warning).

##  Names and Identifiers

Identifiers consist of a sequence of letters, digits, the period ( ` . ` ) and
the underscore. They must not start with a digit nor underscore, nor with a
period followed by a digit. [ Reserved
](/link/Reserved?package=base&version=3.6.2) words are not valid identifiers.

The definition of a _letter_ depends on the current locale, but only ASCII
digits are considered to be digits.

Such identifiers are also known as _syntactic names_ and may be used directly
in  R  code. Almost always, other names can be used provided they are quoted.
The preferred quote is the backtick (  `  ), and ` [ deparse
](/link/deparse?package=base&version=3.6.2) ` will normally use it, but under
many circumstances single or double quotes can be used (as a character
constant will often be converted to a name). One place where backticks may be
essential is to delimit variable names in formulae: see ` [ formula
](/link/formula?package=base&version=3.6.2) ` .

##  Details

Three types of quotes are part of the syntax of  R  : single and double
quotation marks and the backtick (or back quote,  `  ). In addition, backslash
is used to escape the following character inside character constants.

##  See Also

` [ Syntax ](/link/Syntax?package=base&version=3.6.2) ` for other aspects of
the syntax.

` [ sQuote ](/link/sQuote?package=base&version=3.6.2) ` for quoting English
text.

` [ shQuote ](/link/shQuote?package=base&version=3.6.2) ` for quoting OS
commands.

The ‘R Language Definition’ manual.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2FQuotes&utm