Convert elements of a Vector to Strings in R Language - toString() Function Last Updated : 25 Oct, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report toString() function in R Programming Language is used to produce a single character string describing an R object. Syntax: toString(x, width = NULL) Parameters: x: R objectwidth: Suggestion for the maximum field width. Values of NULL or 0 indicate no maximum. The minimum value accepted is 6 and smaller values are taken as 6 toString() function in R Language ExampleExample 1: Basic example of toString() Function in R Language R # R program to illustrate # toString function # Initializing a string vector x <- c("GFG", "Geeks", "GeeksforGeekss") # Calling the toString() function toString(x) Output : [1] "GFG, Geeks, GeeksforGeekss"Example 2: Formatting with toString() Function in R Language R # R program to illustrate # toString function # Initializing a string vector x <- c("GFG", "Geeks", "GeeksforGeekss") # Calling the toString() function toString(x, width = 2) toString(x, width = 8) toString(x, width = 10) Output: [1] "GF...." [1] "GFG, ...." [1] "GFG, G...."Example 3: Convert Matrix to String in R R # Matrix having 3 rows and 3 columns # filled by a single constant 5 mat <- (matrix(5, 3, 3)) print(mat) str <- toString(mat) print("String") print(str) Output: [,1] [,2] [,3] [1,] 5 5 5 [2,] 5 5 5 [3,] 5 5 5 [1] "String" [1] "5, 5, 5, 5, 5, 5, 5, 5, 5" Comment More infoAdvertise with us Next Article Convert String to Integer in R Programming - strtoi() Function K Kanchan_Ray Follow Improve Article Tags : R Language R Vector-Function R String-Functions Similar Reads 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: Python3 1== # R program to convert an object to string # Creating a vector x <- c("Geeks", "for 1 min read Case conversion of a String in R Language - toupper(), tolower(), casefold() and cartr() Function In this article, we are going to see case conversion of a string in R Programming Language. R - toupper() toupper() function in R Language is used to convert the lowercase letters to uppercase. Syntax: toupper(x)Â Parameters:Â x: character vector Example:Â R # R program to illustrate # uppercase of 2 min read Function to convert set of categorical variables to single vector in R Converting a set of categorical variables to a single vector in R can be efficiently done using several techniques, such as factor levels, dummy variables, or one-hot encoding. Here, I will explain a function that combines these categorical variables into a single vector. This process involves conve 3 min read Convert String to Single Quote Text in R Programming - sQuote() Function sQuote() function in R Language is used to convert the given string or character vector into single quote text. Syntax: sQuote(x) Parameters: x: specified string, character vector Example 1: Python3 # R program to illustrate # sQuote function # Initializing a string x <- "GeeksforGeeks" 1 min read Convert String to Integer in R Programming - strtoi() Function strtoi() function in R Language is used to convert the specified string to integers. Syntax: strtoi(x, base=0L) Parameters: x: character vector base: integer between 2 and 36 inclusive, default is 0 Example 1: Python3 # R program to illustrate # strtoi function # Initializing some string vector x 1 min read Convert values of an Object to Logical Vector in R Programming - as.logical() Function as.logical() function in R Language is used to convert an object to a logical vector. Syntax: as.logical(x)Parameters:Â x: Numeric or character object R - as.logical() Function ExampleExample 1: Basic example of as.logical() Function in R Programming Language.R # R Program to convert # an object to l 1 min read Like