Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 513
Stephen Henderson Avatar asked Dec 13 '13 17:12

Stephen Henderson


People also ask

Are single and double quotes interchangeable?

In HTML, CSS and JavaScript code, single and double quotes are interchangeable.

What do quotation marks mean in R?

A key characteric of objects containing (only) numeric values is that they can be used for all sorts of numerical calculations (sum, multiply, divide,…). An R-object may also contain so called “character values”. Character values are text entries. A character value is entered into R by using quotation marks: "" or '' .

What is the difference between single and double quotation marks in coding?

As far as language syntax is concerned, there is no difference in single or double quoted string. Both representations can be used interchangeably. However, if either single or double quote is a part of the string itself, then the string must be placed in double or single quotes respectively.

How do you replace single quotes with double quotes?

Use the String. replace() method to replace double with single quotes, e.g. const replaced = str. replace(/"/g, "'"); . The replace method will return a new string where all occurrences of double quotes are replaced with single quotes.


1 Answers

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."

like image 138
Waldir Leoncio Avatar answered Sep 24 '22 01:09

Waldir Leoncio