Re: [Rd] Apropos sprintf behavior

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 16 Feb 2005 - 04:17:14 EST

Patches against the current R-devel sources will be considered, but note that 'x' is already there, and there is rawToChar.

On Tue, 15 Feb 2005, Steve Dutky wrote:

> If changes to sprintf behavior are being considered, would it
> be possible to allow some of the other K&R conversion
> specifiers?
>
> xX - for integer to hex conversion, and
> c - for ascii value to character conversion
>
> would all be useful for me.
>
> Thanks, Steve Dutky
>
> On Mon, 14 Feb 2005 11:02:20 +0000 (GMT), Prof Brian Ripley
> wrote:
>
> +On Mon, 14 Feb 2005, Wolfgang Huber wrote:
> +
> +> Dear Prof. Ripley,
> +>
> +> Would it be possible to make sprintf accept vector
> arguments?
> +> I.e. allow expressions like
> +> sprintf("%04d", 1:3)
> +> to produce something like what currently needs to be done
> via
> +> sapply(1:3, function(i) sprintf("%04d",i))
> +
> +I have thought about this, but it is not really clear what
> the right thing
> +would be here with multiple arguments. What should
> +
> +sprintf(("%04d %s", 1:3, "abc")
> +
> +do? Produce a character vector of length 1 or 3? If of
> length 1,
> +"0001 0002 0003 abc" or "0001 2 0003 abc"?
> +
> +I guess the most R-like thing would be to recycle args to
> the length of
> +the longest and then use them in parallel, but that can be
> done fairly
> +easily by *apply.
>
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Feb 16 03:36:28 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Feb 2005 - 04:36:01 EST