How to use strrep() function In R Language

This function is used to get the N character strings in a single string.

Syntax:

strrep( “string”,N)

Example: R program to get N character strings using strrep() function

R




# get 2 times
print(strrep( "Hello_Geek",2))
 
print("-----")
 
# get 10 times
print(strrep( "Python",10))
 
print("-----")
 
# get 3 times
print(strrep( "java",3))
 
print("-----")
 
# get 4 times
print(strrep("dbms",4))
 
print("-----")
 
# get 5 times
print(strrep( "sql",5))
 
print("-----")
 
# get 7 times
print(strrep("big data",7))


 
 

Output:

 

[1] “Hello_GeekHello_Geek”

[1] “—–“

[1] “PythonPythonPythonPythonPythonPythonPythonPythonPythonPython”

[1] “—–“

[1] “javajavajava”

[1] “—–“

[1] “dbmsdbmsdbmsdbms”

[1] “—–“

[1] “sqlsqlsqlsqlsql”

[1] “—–“

[1] “big databig databig databig databig databig databig data”

 



Repeat Character String N Times in R

In this article, we will discuss how to repeat the character string N times in the R programming language. Character string means a set of characters .

Example:

“Hello Geek”,”Python”,”Languages_Python” are some examples

Similar Reads

Method 1: Using replicate() method

This function used to give n replicas from the character string...

Method 2: Using rep() method

...

Method 3 : Using paste along with replicate

...

Method 4: Using strrep() function

...

Contact Us