Substitute characters of a String in R Programming - chartr() Function Last Updated : 23 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report chartr() function in R Programming Language is used to do string substitutions. It replaces all the matches of the existing characters of a string with the new characters specified as arguments. Syntax: chartr(old, new, x) Parameters: old: old string to be substitutednew: new stringx: target string Example 1: R # R program to illustrate # chartr function # Initializing a string x <- "Geeks GFG" # Calling the chartr() function # which will substitute G with Z # to the above specified string chartr("G", "Z", x) Output : [1] "Zeeks ZFZ" Example 2: R # R program to illustrate # chartr function # Initializing a string x <- "GeeksforGeeks Geeks" # Calling the chartr() function # which will substitute G with 1, # k with 2 and s with 3 # to the above specified string chartr("Gks", "123", x) Output: [1] "1ee23for1ee23 1ee23" Comment More infoAdvertise with us Next Article Convert Character value to ASCII value in R Programming - charToRaw() Function K Kanchan_Ray Follow Improve Article Tags : R Language R-strings R String-Functions Similar Reads Extracting Substrings from a Character Vector in R Programming - substring() Function substring() function in R Programming Language is used to extract substrings in a character vector. You can easily extract the required substring or character from the given string. Syntax: substring(text, first, last) Parameters: text: character vectorfirst: integer, the first element to be replac 1 min read Create Repetitions of a String in R Programming - strrep() Function strrep() Function in R Language is used to create specified number of repetitions of a specified string. Syntax: strrep(string, n) Parameter: string: specified string n: number of repetitions Example 1: Python3 1== # R Program to illustrate # the use of strrep function # String to be repeated x < 1 min read Convert Character value to ASCII value in R Programming - charToRaw() Function charToRaw() function in R Language is used to convert the given character to their corresponding ASCII value or "raw" objects. Syntax: charToRaw(x)Parameters: x: Given characters to be converted  Example 1: Python3 # R program to illustrate # charToRaw function # Calling charToRaw() function over 1 min read 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 Convert a Numeric Object to Character in R Programming - as.character() Function as.character() function in R Language is used to convert a numeric object to character object. Syntax: as.character(x) Parameters: x: Numeric Object Example 1: Python3 1== # R program to convert a numeric object # to character object # Calling as.character() function as.character(1) as.character(2 + 1 min read Print a Formatted string in R Programming - sprintf() Function The sprintf() function is used to create formatted strings in R. These formatted strings enable us to insert variables and values into a string while controlling their appearance and formatting. The sprintf() function uses a user-defined format to return a formatted string by inserting the correspon 2 min read Like