Re: [R] sprintf question

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 04 May 2006 - 02:35:46 EST

Try this:

do.call(sprintf, c("%9.2f\t%d\t%d\t%8.3f", as.list(v[iv])))

On 5/3/06, Paul Roebuck <roebuck@mdanderson.org> wrote:
> How would one go about getting sprintf to use the
> values of a vector without having to specify each
> argument individually?
>
> > v <- c(1, 2, -1.197114, 0.1596687)
> > iv <- c(3, 1, 2, 4)
> > sprintf("%9.2f\t%d\t%d\t%8.3f", v[3], v[1], v[2], v[4])
> [1] " -1.20\t1\t2\t 0.160"
>
> Essentially, desired effect would be something like:
> > sprintf("%9.2f\t%d\t%d\t%8.3f", v[iv]) # wish it worked
>
> ----------------------------------------------------------
> SIGSIG -- signature too long (core dumped)
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 04 03:56:38 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 04 May 2006 - 06:10:04 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.