To represent a string or character vector value in R, you can use one of the following.
- Single quotation mark( ‘ ‘ )
- Double quotation mark( ” ” )
Let’s see how to print double quotes in R.
dQuote in R
The dQuote() is a built-in R function used to convert the given string or character vector into double quote text. It takes a specified string or character vector as an argument and returns the double-quoted text.
To convert a string or character vector to double-quote text in R, use the dQuote() function.
The purpose of the dQuote() function is to provide a markup for quoting text to be used in the R output. The choice of the appropriate quotation marks depends on both the locale and the available character sets.
The dQuote() method accepts x as a specified string, character vector.
data <- "Expelli Armus" dQuote(data)
 "“Expelli Armus”"
From the output, you can see that it appends one more pair of double quotations. So our output has two double-quoted text.
Let’s see another example of the dQuote() method. Let’s pass the integers in the form of a string and see the output.
data <- "1 + 2 / 2 * 4" dQuote(data)
 "“1 + 2 / 2 * 4”"
And we get the output text with double double-quotes.
That is it for this tutorial.
Krunal Lathiya is an Information Technology Engineer by education and web developer by profession. He has worked with many back-end platforms, including Node.js, PHP, and Python. In addition, Krunal has excellent knowledge of Data Science and Machine Learning, and he is an expert in R Language. Krunal has written many programming blogs, which showcases his vast expertise in this field.