The dQuote() function in R is used to add double quotes around a string.
This function is specifically helpful when you need to present strings in a formatted way, such as in printed output or in constructing messages and plots.
Syntax
dQuote(x)
Parameters
x: It is a string or character vector.
Return value
It returns a character vector with double quotes around each element.
Example 1: Basic usage
string <- "Expelli Armus"
dQuote(string)
Output
[1] "“Expelli Armus”"
Example 2: Pass integer as a string
expression <- "1 + 2 / 2 * 4"
dQuote(expression)
Output
[1] "“1 + 2 / 2 * 4”"
For single quotes, use the sQuote() function, which works similarly.
Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.