[R] multiple plot in odfWeave

From: Laurence Amilhat <Laurence.Amilhat_at_toulouse.inra.fr>
Date: Tue, 05 Jun 2007 08:55:19 +0200


Hello R users,

I found the odfWeave package to create an odf document. It seems to be a very nice tool.
So i tried to used it to create a report with multiple plot:

I create an odt file with some code inside: I connect to a mysql database
I get a list of projects
foreach project I would like to make a plot (a map exactly)

then in a R console I use the odfweave (inFile, outFile) function.

When I try this, with only one program without the loop on the program names, it
draw a map on my odt file, but when i a m doing the loop it doesn't work.

When i try to launch the plot (using the loop) in R console directly, without odfweave, it also works.

Do you know if it is possible to make successive plot in odfWeave document?

Thank you for your help,

Laurence.

Here the code:

My odt file: test2.odt

<<loadData, results = hide, echo = FALSE>>=

@

<<Connection, echo = FALSE, fig = TRUE>>=

library("RMySQL")
library(maps)
library(mapdata)
library(spmaps)
library(grid)
library(plotrix)

drv <- dbDriver("MySQL")
con <- dbConnect(drv, user="lamilhat", password="******", dbname="Aquagenome", host="mymachine.toulouse.inra.fr")

@

Liste des projets:

<<carte2, echo = FALSE, results= verbatim, fig = TRUE>>=

lp <- dbSendQuery(con, "SELECT nom FROM projets") projets <- fetch(lp)
nbr=dim(projets)[1]
for (i in 1:nbr)
{

    monprojet=(projets)[i,1]
    myquery=paste("SELECT s.longitude, s.latitude, o.orgashort FROM organisme o JOIN scientist s ON o.codeorga=s.codeorga JOIN partenaire p ON p.codescientist=s.codescientist JOIN projets ON projets.codeproj=p.codeproj WHERE projets.nom LIKE \"",monprojet,"\" ORDER BY s.longitude", sep="")

    rs <- dbSendQuery(con, myquery )
    df <- fetch(rs)

    print(df)

    map(database="world", xlim=c(-15,40),ylim=c(27,71), fill=TRUE, col="#FFFFCC")

    points(df$longitude,df$latitude, col="red", pch=16)                                                  

spread.labels(df$longitude,df$latitude,df$orgashort,0,bg="#CCFFFF", border=TRUE, cex=0.8, xpad=0.5, ypad=0.8, font=6) }

@

Then in the R console:

>library (odfWeave)
>inFile <- "/home/lamilhat/AQUAGENOME/PRESENTATION/RAPPORTS/test_2.odt"
>outFile <-

"/home/lamilhat/AQUAGENOME/PRESENTATION/RAPPORTS/test_2_out.odt"

>imageDefs <- getImageDefs()
>imageDefs$dispWidth <- 7
>imageDefs$dispHeight <- 6
>setImageDefs(imageDefs)

>odfWeave(inFile, outFile)

-- 
====================================================================
= Laurence Amilhat    INRA Toulouse 31326 Castanet-Tolosan     	   = 
= Tel: 33 5 61 28 53 34   Email: laurence.amilhat_at_toulouse.inra.fr =

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 05 Jun 2007 - 07:05:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Jun 2007 - 09:31:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.