dQuote() in R: How to Use dQuote() Function in R

To represent a string or character vector value in R, you can use one of the following.

  1. Single quotation mark( ‘ ‘ )
  2. 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.

Syntax

dQuote(x)

Parameters

The dQuote() method accepts x as a specified string, character vector.

Example

data <- "Expelli Armus"

dQuote(data)

Output

[1] "“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)

Output

[1] "“1 + 2 / 2 * 4”"

And we get the output text with double double-quotes.

That is it for this tutorial.

Leave a Comment