str_c() Function of stringr Package in R Last Updated : 02 Jun, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will discuss str_c() function which is available in stringr package. Before going to this method, we have to install and import stringr package. Syntax: Install- install.packages("stringr") Import - library("stringr")str_c() Methods This function is used to combine the multiple strings by a separator. Syntax: str_c("string1","string2",...............,sep) where, strings are the input strings separated by comma and sep is the second parameter used to separate deach string with a delimiter. Example 1: In this example, we are concatenating 5 strings without separator. R # load the stringr library library(stringr) # combine 5 strings without separator print(str_c("Welcome","to","geeks", "for","geeks")) Output: [1] "Welcometogeeksforgeeks" Example 2: In this example, we are concatenating 5 strings by different separators. R # load the stringr library library(stringr) # combine 5 strings with comma separator print(str_c("Welcome","to","geeks", "for","geeks",sep=",")) # combine 5 strings with space separator print(str_c("Welcome","to","geeks", "for","geeks",sep=" ")) # combine 5 strings with & separator print(str_c("Welcome","to","geeks", "for","geeks",sep="&")) [1] "Welcome,to,geeks,for,geeks" [1] "Welcome to geeks for geeks" [1] "Welcome&to&geeks&for&geeks" Comment More infoAdvertise with us Next Article Load R Package From Character String S sravankumar_171fa07058 Follow Improve Article Tags : R Language R Functions R-Packages Similar Reads basic_string c_str function in C++ STL The basic_string::c_str() is a built-in function in C++ which returns a pointer to an array that contains a null-terminated sequence of characters representing the current value of the basic_string object. This array includes the same sequence of characters that make up the value of the basic_string 2 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 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 Load R Package From Character String R packages are collections of R functions, data, and compiled code in a well-defined format. To use the functionalities provided by an R package, you need to load it into your R session. Typically, this is done using the library() or require() functions. However, there are scenarios where you might 4 min read String Concatenation in R Programming String concatenation is a way of appending two or more strings into a single string whether it is character by character or using some special character end to end. There are many ways to perform string concatenation. Example: Input: str1 = 'Geeks' str2 = 'for' str3 = 'Geeks' Output: 'GeeksforGeeks 3 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