Create Repetitions of a String in R Programming – strrep() Function
Last Updated :
05 Jun, 2020
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:
x < - "Geeks"
strrep(x, 5 )
|
Output:
[1] "GeeksGeeksGeeksGeeksGeeks"
Example 2:
x < - "Geeks"
y < - "4 "
strrep(x, 5 )
strrep(y, 5 )
strrep(x, 5 )
|
Output:
[1] "GeeksGeeksGeeksGeeksGeeks"
[1] "4 4 4 4 4 "
[1] "GeeksGeeksGeeksGeeksGeeks"
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...