I'm trying to understand what backticks do in R.
From what I can tell, this is not explained in the ?Quotes
documentation page for R.
For example, at the R console:
"[["
# [1] "[["
`[[`
# .Primitive("[[")
It seem to be returning the equivalent to:
get("[[")
They are equivalent to verbatim. For example... try this:
gives error
doesn't give error
A pair of backticks is a way to refer to names or combinations of symbols that are otherwise reserved or illegal. Reserved are words like
if
are part of the language, while illegal includes non-syntactic combinations likec a t
. These two categories, reserved and illegal, are referred to in R documentation asnon-syntactic names
.Thus,
and
As a commenter mentioned,
?Quotes
does contain some information on the backtick, underNames and Identifiers:
This prose is a little hard to parse. What it means is that for R to parse a token as a name, it must be 1) a sequence of letters digits, the period and underscores, that 2) is not a reserved word in the language. Otherwise, to be parsed as a name, backticks must be used.
Also check out
?Reserved
:In addition, Advanced R has some examples of how backticks are used in expressions, environments, and functions.
Here is an incomplete answer using improper vocabulary: backticks can indicate to R that you are using a function in a non-standard way. For instance, here is a use of
[[
, the list subsetting function:extract element one, the usual way
extract element one using the
[[
function