[R] empty string

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Thu Jan 15 17:59:32 CET 2004


Thomas Lumley wrote:

> paste(rep(" ",n), collapse="")
> 
> gives a string of n spaces.
> 

  Is that more or less efficient/faster or slower than using sprintf:

sprintf(paste("%",n,"s",sep='')," ")

  A quick test shows it to take about two-thirds the CPU time of the 
paste(rep()) solution.

  Not that it matters - I cant see something like this ever being a 
significant part of any calculation!

Baz




More information about the R-help mailing list