Re: [R] vector in filename

From: hadley wickham <>
Date: Fri, 18 Apr 2008 08:20:59 -0500

On Thu, Apr 17, 2008 at 8:05 PM, [Ricardo Rodriguez] Your XEN ICT Team <> wrote:
> Hi,
> I am trying to generate a group of graphics with an iteration. Some
> thing like this...
> x=1
> y=1
> max=10
> myfiles <- paste("foo", x:max, ".png", sep="")
> while (x =< max)
> {
> png(file=myfiles, pointsize = 20, width = 600, height = 600,
> units = "px", bg="#eaedd5")
> plot(x,y)
> x=x+1
> y=y+1
> }

> I am getting only one *.png file with the name of the first position in
> myfiles and the content of the last graphic in the iteration. Please,
> could you tell me if it is possible to iterate file= in any other way?

Have you looked at ?png :

filename: the name of the output file. The page number is substituted

          if a C integer format is included in the character string, as
          in the default.  (The result must be less than 'PATH_MAX'
          characters long, and may be truncated if not. See
          'postscript' for further details.)  Tilde expansion is
          performed where supported by the platform.

so the default filename ("Rplot%03d.jpeg") already does what you want.



______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 18 Apr 2008 - 13:22:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Apr 2008 - 15:30:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive