Text in R is represented by character vectors. The text often is referred to as a string in computer programming. A character vector is a vector consisting of characters. To assign a value to a character vector, use the <- (left arrow) operator.
To find the length of the character vector, use the length() function. To test whether it is a character vector or not, use the is.character() function.
sQuote() in R
The sQuote() is a built-in R function used to convert the given string or character vector into single quote text. It takes a specified string or character vector as argument and returns the single quote text.
To convert a string or character vector to single-quote text in R, use the sQuote() function.
The purpose of the sQuote() 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 sQuote() function takes the x as a specified string, character vector.
dt <- "Aloho Mora" sQuote(dt)
 "‘Aloho Mora’"
Let’s see another example of the sQuote() method. Let’s pass the integers in the form of a string and see the output.
data <- "11 + 21 / 19 * 18" sQuote(data)
 "‘Aloho Mora’"
Let’s pass the special symbols as a character vector and see its output.
d <- "@!+_)(" sQuote(d)
And we get the result in the single-quotation mark enveloped by the double-quotation mark.
That is it for sQuote() function in R.
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.