An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20040115/ca7f4410/attachment.pl
empty string
3 messages · Wolski, Thomas Lumley, Barry Rowlingson
On Thu, 15 Jan 2004, Wolski wrote:
Hi! How to generate a empty string of a precise length without using a loop?
paste(rep(" ",n), collapse="")
gives a string of n spaces.
-thomas
I need a empty string (char **) to pass it with .C function to a c dll. The c routine writes the result into the string. Eryk. Dipl. bio-chem. Eryk Witold Wolski @ MPI-MG Dep. Vertebrate Genomics Ihnestrasse 73 14195 Berlin 'v' tel: 0049-30-84131285 / \ mail: wolski at molgen.mpg.de ---W-W---- http://www.molgen.mpg.de/~wolski [[alternative HTML version deleted]]
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
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