Related Articles

Related Articles

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to illustrate 
# the use of strrep function
  
# String to be repeated
x <- "Geeks"
  
# Calling strrep() function
strrep(x, 5)

chevron_right


Output:

[1] "GeeksGeeksGeeksGeeksGeeks"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to illustrate 
# the use of strrep function
  
# String to be repeated
x <- "Geeks"
y <- "4 "
  
# Calling strrep() function
strrep(x, 5)
strrep(y, 5)
strrep(x, 5)

chevron_right


Output:

[1] "GeeksGeeksGeeksGeeksGeeks"
[1] "4 4 4 4 4 "
[1] "GeeksGeeksGeeksGeeksGeeks"
My Personal Notes arrow_drop_up
Recommended Articles
Page :