[R] R as a programming language

Alberto Monteiro albmont at centroin.com.br
Thu Nov 8 20:27:46 CET 2007


Duncan Murdoch wrote:
>
>> and there's always sprintf() for those moments when you
>> want neat formatting.
> 
> That's good when you want good control over the formatting, but it 
> doesn't tend to be all that readable, with the variables all listed 
> at the end, instead of in between the bits of string.
>
As the old saying goes, you can eat the cake and have it:

x <- rnorm(1)
cat("x is close to ", sprintf("%.1lf", x), " and closer to ",
  sprintf("%.10lf", x), "\n", sep = "")

:-)

I am using R as a generic programming language for doing 
jobs in Windows that I can't do using DOS batch - things 
like taking a text in Latin-1 and removing the accented 
characters, or looping through a directory and renaming 
files with weird names, or creating a .wpl file with the mp3s.

Alberto Monteiro



More information about the R-help mailing list