[R] creating a ps. file
christopher ciotti
chris_ciotti at yahoo.com
Mon Mar 15 15:17:13 CET 2004
mike.campana at freesurf.ch wrote:
>Dear all
>
>I wrote a routine. At the end of each cycle of the loop I would like to
>save the result (plot) in a postcriptfile.
>Of course if I just use dev.print in the following way:
>dev.print(device=postcript, 'c:/Rfigures/plot_1.ps")
>I overwrite my results with the second cycle of the loop. I suppose
>there is a way to define the file name so that several plots are
>created(plot_1,plot_2...).
>
>Could you give me an advice? Thanks a lot
>
>Best Regards
>Mike
>
>
>
Hello -
I've never done this in R (I'm a total 'R' newbie) but in C or Java,
I've used the loop counter as a postfix (or prefix) for the file name.
You could do it like this (non-R code):
int max = 10;
for(int i = 1; i < max; i++){
[ . . .] //code for plotting etc
writer = PdfWriter.getInstance(document, new
FileOutputStream(pdfTitle + "_"
+ i + ".pdf"));
}
This would give (assuming pdfTitle == "plot"): plot_1.pdf, plot_2.pdf
and so and so forth
Others may be able to provide pointers etc for writing loops in R. Hope
this helps.
--
chris ciotti (chris_ciotti at yahoo.com)
PGP ID: 0xE94BB3B7
More information about the R-help
mailing list