In R, is it possible to repeat a string n number of times? If yes, how to do that?

Yes it is possible to repeat a string n number of times in R.

For doing that we can use replicate or rep function

replicate(3, "string")

Output

[1] "string" "string" "string"

rep("string", 2)

Output

[1] "string" "string"



Your Answer

Interviews

Parent Categories