[R] multiple plot in odfWeave

Laurence Amilhat Laurence.Amilhat at toulouse.inra.fr
Tue Jun 5 10:04:15 CEST 2007


Hello,

To clarify my question:
When I launch the odfWeave function in the R console,
I see the several maps in the R graphic window, but I cannot open the 
output file .odt
I get the following error:
format error in the subdocument content.xml position 123,82 (row,col)

Thanks,

Laurence



Laurence Amilhat a écrit :
> 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 =



More information about the R-help mailing list