Are double "" and single '' quotes (always) interchangeable in R?

Stephen Henderson picture Stephen Henderson · Dec 13, 2013 · Viewed 12.6k times · Source

This is perhaps rather a minor question...

but just a moment ago I was looking through some code I had written and noticed that I tend to just use ="something" and ='something_else' completely interchangeably, often in the same function.

So my question is: Is there R code in which using one or other (single or double quotes) has different behaviour? Or are they totally synonymous?

Answer

Waldir Leoncio picture Waldir Leoncio · Dec 13, 2013

According to http://stat.ethz.ch/R-manual/R-patched/library/base/html/Quotes.html, "[s]ingle 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."