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

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"


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


[1] "‘Aloho Mora’"

Let’s pass the special symbols as a character vector and see its output.

d <- "@!+_)("


[1] "‘@!+_)(’"

And we get the result in the single-quotation mark enveloped by the double-quotation mark.

That is it for sQuote() function in R.

See also

dQuote() function in R

Leave a Comment