Convert an Object to a String in R Programming – toString() Function
toString() function in R Language is used to convert an object into a single character string.
Syntax: toString(x, width)
Parameters:
x: Object
width: maximum string width
Example 1:
# R program to convert an object to string # Creating a vectorx <- c("Geeks", "for", "geeks") # Calling toString() FunctiontoString(x)toString(x, width = 12) |
Output:
[1] "Geeks, for, geeks" [1] "Geeks, f...."
Example 2:
# R program to convert an object to string # Creating a matrixx <- matrix(c(1:9), 3, 3) # Calling toString() FunctiontoString(x) |
Output:
[1] "1, 2, 3, 4, 5, 6, 7, 8, 9"


