Re: [R] vector in filename

2008-04-18 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi,

Simon Blomberg wrote:
 How about this:

 x - 1
 y - 1
 mmax - 10

 my.files - paste(foo, x:mmax, .png, sep=)

 for (i in my.files) {
   png(filename=i, pointsize=20, width=600, height=600, units=px,
   bg=#eaedd5)
   plot(x, y)
   dev.off()
   x - x+1
   y - y+1
 }
   

It does the trick! Thanks.
 Normally I would avoid for loops, but I think this application is a
 legitimate use.

Please, why do you avoid looping normally? Thanks again.

Greetings,

Ricardo

-- 
Ricardo Rodríguez
Your XEN ICT Team

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] vector in filename

2008-04-18 Thread hadley wickham
On Thu, Apr 17, 2008 at 8:05 PM, [Ricardo Rodriguez] Your XEN ICT Team
[EMAIL PROTECTED] 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)
 dev.off()
 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.

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] vector in filename

2008-04-18 Thread [Ricardo Rodriguez] Your XEN ICT Team
Thanks Hadley,

hadley wickham wrote:
 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.

 Hadley

   

Yes, I've read this help page. But as far as I understand, this only 
allows to generated a paged file name, but not to include the value of 
a variable in the file name. Foo is a dummy name. It is only the 
numerical part of the name what variates in the samples above. I guess 
it won't be difficult to get Foo from values in a vector once I 
understand how the whole thing does work.

Cheers,

Ricardo


-- 
Ricardo Rodríguez
Your XEN ICT Team

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.