As an absolute beginner I'm reading and practicing with the Verzani doc to learn R. Now, being an expert latex user who wants to integrate graphical capabilities if R and latex, using the "Simple" library and the simple.scatterplot examples I had a go at: 1) Including the resulting graph into a doc.snw then compiled through sweave & latex; 2) Produce the graph in pdf format directly (using pdf(filename) at the very beginning and before issuing the "simple.scatterplot " command) and including it into the latex file via \includegraphics. In both cases the graph is a set of numbered rectangles. Investigating into the pdf files generated by R I found that they are made of 2 pages: the first contains those nasty rectangles while the second the "right" graph that should be inserted. The same result comes out if I try the "layout" command example in the help of the same package. My question is: is there a way to tell R to produce the second page only as a final pdf file? If not, any suggestion for a way out. Ciao Vittorio
Hi v.demart at libero.it wrote:> As an absolute beginner I'm reading and practicing with the Verzani doc to learn R. > > Now, being an expert latex user who wants to integrate graphical capabilities if R and latex, using the "Simple" library and the simple.scatterplot examples I had a go at: > 1) Including the resulting graph into a doc.snw then compiled through sweave & latex; > 2) Produce the graph in pdf format directly (using pdf(filename) at the very beginning and before issuing the "simple.scatterplot " command) and including it into the latex file via \includegraphics. > > In both cases the graph is a set of numbered rectangles. Investigating into the pdf files generated by R I found that they are made of 2 pages: the first contains those nasty rectangles while the second the "right" graph that should be inserted. > > The same result comes out if I try the "layout" command example in the help of the same package. > > My question is: is there a way to tell R to produce the second page only as a final pdf file? > If not, any suggestion for a way out.The "nasty rectangles" are the output of the layout.show() function. This function draws a simple diagram (consisting of nasty rectangles) to indicate the regions that a call to layout() has set up. It is designed to help users to understand what on earth the layout() function is doing. (It is NOT a necessary part of setting up an arrangement of plots using the layout() function.) I suspect that the author of "simpleR" may have accidentally left the layout.show() call in simple.scatterplot() when copying the example from the layout() help file (apologies to John Verzani if this is an unfair diagnosis). So the immediate solution to your problem is to remove the line ... layout.show(nf) ... from simple.scatterplot(). The output should then be a single page which should "include" ok in latex. The larger problem of how to get at individual pages of output is probably best solved using something like the "onefile" argument to devices. For example, look at the files produced by ... pdf(onefile=FALSE) example(layout) ... and at the help page for pdf() to see more about how to do this. Hope that helps Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
Paul Murrell [r-help] <20/10/03 09:13 +1300>:> Hi >..................................................... > The "nasty rectangles" are the output of the layout.show() function. > This function draws a simple diagram (consisting of nasty rectangles) to > indicate the regions that a call to layout() has set up. It is designed > to help users to understand what on earth the layout() function is > doing. (It is NOT a necessary part of setting up an arrangement of > plots using the layout() function.) > > I suspect that the author of "simpleR" may have accidentally left the > layout.show() call in simple.scatterplot() when copying the example from > the layout() help file (apologies to John Verzani if this is an unfair > diagnosis). > > So the immediate solution to your problem is to remove the line ... > > layout.show(nf) > > ... from simple.scatterplot(). The output should then be a single page > which should "include" ok in latex. > > The larger problem of how to get at individual pages of output is > probably best solved using something like the "onefile" argument to > devices. For example, look at the files produced by ... > > pdf(onefile=FALSE) > example(layout) > > ... and at the help page for pdf() to see more about how to do this. > > Hope that helps >...............................Yes, Paul, definitely it helps. Thanks! I obtained what I wanted. Now, I want to control the output of the pdf() command making it write a specific file chosen by me and not the system. After reading the help page for the pdf, I was unable to do it. E.g. I issued onefile<-FALSE pdf(file=ifelse(onefile,,"vic.pdf") example(layout) And I obtained a 5-pages vic.pdf with page 1-4 full of "nasty rectangles" of any kind and page 5 with the right picture. Please help Ciao from Rome - Vittorio
Hi Vittorio wrote:> Paul Murrell [r-help] <20/10/03 09:13 +1300>: > >>Hi >>..................................................... >>The "nasty rectangles" are the output of the layout.show() function. >>This function draws a simple diagram (consisting of nasty rectangles) to >>indicate the regions that a call to layout() has set up. It is designed >>to help users to understand what on earth the layout() function is >>doing. (It is NOT a necessary part of setting up an arrangement of >>plots using the layout() function.) >> >>I suspect that the author of "simpleR" may have accidentally left the >>layout.show() call in simple.scatterplot() when copying the example from >>the layout() help file (apologies to John Verzani if this is an unfair >>diagnosis). >> >>So the immediate solution to your problem is to remove the line ... >> >> layout.show(nf) >> >>... from simple.scatterplot(). The output should then be a single page >>which should "include" ok in latex. >> >>The larger problem of how to get at individual pages of output is >>probably best solved using something like the "onefile" argument to >>devices. For example, look at the files produced by ... >> >> pdf(onefile=FALSE) >> example(layout) >> >>... and at the help page for pdf() to see more about how to do this. >> >>Hope that helps >>............................... > > > Yes, Paul, definitely it helps. Thanks! > > I obtained what I wanted. > > Now, I want to control the output of the pdf() command making it write > a specific file chosen by me and not the system. After reading the > help page for the pdf, I was unable to do it. > > E.g. I issued > > onefile<-FALSE > pdf(file=ifelse(onefile,,"vic.pdf") > example(layout) > > > And I obtained a 5-pages vic.pdf with page 1-4 full of "nasty > rectangles" of any kind and page 5 with the right picture.You need something like ... pdf("yourname%03d.pdf", onefile=FALSE) example(layout) Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/