On Thu, 07 Apr 2005 13:24:42 +0200 Christoph Lehmann wrote:> Hi > I use sweave and have a problem with the following figure, but not > with other figures: > > tt <- data.frame(c("a", "b", "c"), c(1.2, 3, 4.5)) > names(tt) <- c("x1", "x2") > bwplot(x2 ~x1, data = tt) > > ok now in sweave: > > \begin{figure}[H] > \begin{center} > <<echo=FALSE, fig=TRUE, height=5, width=10>>> lset(col.whitebg()) > bwplot(x2 ~x1, data = tt) > @ > \caption{xxx} > \end{center} > \end{figure} > > PROBLEM: > the pdf of the figure is not correctly created (neither the esp) and > the error I get from sweave is: > pdf inclusion: required page does not exist <0>This is covered by FAQ 7.22. (you need to print() the plot) Z> thanks for help > > christoph > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
>>>>> On Thu, 07 Apr 2005 13:24:42 +0200, >>>>> Christoph Lehmann (CL) wrote:> Hi > I use sweave and have a problem with the following figure, but not with > other figures: > tt <- data.frame(c("a", "b", "c"), c(1.2, 3, 4.5)) > names(tt) <- c("x1", "x2") > bwplot(x2 ~x1, data = tt) > ok now in sweave: > \begin{figure}[H] > \begin{center} > <<echo=FALSE, fig=TRUE, height=5, width=10>> > lset(col.whitebg()) > bwplot(x2 ~x1, data = tt) > @ > \caption{xxx} > \end{center} > \end{figure} > PROBLEM: > the pdf of the figure is not correctly created (neither the esp) and the > error I get from sweave is: > pdf inclusion: required page does not exist <0>>From the Sweave FAQ:A.6 Why do R lattice graphics not work? The commands in package lattice have different behavior than the standard plot commands in the base package: lattice commands return an object of class "trellis", the actual plotting is performed by the print method for the class. Encapsulating calls to lattice functions in print() statements should do the trick, e.g.: <<fig=TRUE>>= library(lattice) print(bwplot(1:10)) @ should work. -- ------------------------------------------------------------------- Friedrich Leisch Institut f?r Statistik Tel: (+43 1) 58801 10715 Technische Universit?t Wien Fax: (+43 1) 58801 10798 Wiedner Hauptstra?e 8-10/1071 A-1040 Wien, Austria http://www.ci.tuwien.ac.at/~leisch
Christoph Lehmann wrote:> Hi > I use sweave and have a problem with the following figure, but not with > other figures: > > tt <- data.frame(c("a", "b", "c"), c(1.2, 3, 4.5)) > names(tt) <- c("x1", "x2") > bwplot(x2 ~x1, data = tt) > > ok now in sweave: > > \begin{figure}[H] > \begin{center} > <<echo=FALSE, fig=TRUE, height=5, width=10>>> lset(col.whitebg()) > bwplot(x2 ~x1, data = tt) > @ > \caption{xxx} > \end{center} > \end{figure} > > PROBLEM: > the pdf of the figure is not correctly created (neither the esp) and the > error I get from sweave is: > pdf inclusion: required page does not exist <0> > > thanks for help > > christophYou need wrap print() round lattice functions to get them to do anything in situations like this. See the Sweave FAQ for this FAQ: http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html#x1-8000A.6 G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On Thu, Apr 07, 2005 at 01:24:42PM +0200, Christoph Lehmann wrote:> \begin{figure}[H] > \begin{center} > <<echo=FALSE, fig=TRUE, height=5, width=10>>> lset(col.whitebg()) > bwplot(x2 ~x1, data = tt) > @ > \caption{xxx} > \end{center} > \end{figure} > > PROBLEM: > the pdf of the figure is not correctly created (neither the esp) and the > error I get from sweave is: > pdf inclusion: required page does not exist <0>You need a print() statement around bwplot() -- see the FAQ. Dirk -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers
Hi I use sweave and have a problem with the following figure, but not with other figures: tt <- data.frame(c("a", "b", "c"), c(1.2, 3, 4.5)) names(tt) <- c("x1", "x2") bwplot(x2 ~x1, data = tt) ok now in sweave: \begin{figure}[H] \begin{center} <<echo=FALSE, fig=TRUE, height=5, width=10>>lset(col.whitebg()) bwplot(x2 ~x1, data = tt) @ \caption{xxx} \end{center} \end{figure} PROBLEM: the pdf of the figure is not correctly created (neither the esp) and the error I get from sweave is: pdf inclusion: required page does not exist <0> thanks for help christoph