1

Is there a simple way to do this in R?

paste0( rep(" ", times=i), collapse="" )

This would be equivalent to Perl's x operator:

" " x $i

I'm hoping for something in the default packages. I would rather not load a package just to do this.

Arnold Cross
  • 199
  • 1
  • 12
  • I think it's fair to duplicate with that question, but this one should not be deleted as it is expressed a bit differently. – thelatemail Jun 10 '20 at 01:41

1 Answers1

1

Yes, you can use strrep

i <- 10
strrep(" ", i)
#[1] "          "
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213