[R] Exporting plots generated by a 'for' loop
sarah.goslee at gmail.com
Sat Apr 28 14:43:16 CEST 2012
Ah, I misread the querent as wanting four plots of three panels each, not a single plot with three panels. Since that's not true, Jim's is the best solution (but mind the missing commas in the iris subsets).
On Apr 28, 2012, at 8:28 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
> On 04/28/2012 08:40 PM, Tejas Kale wrote:
>> I have a 'for' loop that generates a plot with each iteration. I would
>> either like the plots to be stacked one below the other in a single
>> .jpg file or be stored in three different files with each file being
>> named dynamically. The following code is an illustration of my query
>> (but does not accomplish my aim):-
>> for (i in 1:4)
>> Is it possible to fulfill any of my two desires? If not, what is the
>> best alternative I have? I hope I have put forth my question clearly.
> Hi Tejas
> Just rearrange:
> # set up your graphics device
> # set the margins
> # now do the three plots
> for(i in 1:3) plot(iris[i+1]~iris[i])
> # and close the device
> I think you only want three plots, no?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help