R -> PNG
png("xyplot.png") xyplot(mpg ~ disp, mtcars) dev.off()
PNG -> R
library(png) map <- readPNG("map.png") plot(data) rasterImage(map)
+
R -> PDF
pdf("xyplot.pdf") xyplot(mpg ~ disp, mtcars) dev.off()
PostScript -> R
library(grImport) PostScriptTrace("chess_game.eps", "chess_game.xml") chess <- readPicture("chess_game.xml") pawn <- chess[119] xyplot(..., panel=function(...) { grid.symbols(pawn, ...) })
→
R -> R
library(grid) library(lattice) xyplot(mpg ~ disp, mtcars)
xyplot(mpg ~ disp, mtcars) grid.ls()
viewport[ROOT] rect[plot_01.background] viewport[plot_01.toplevel.vp] viewport[plot_01.xlab.vp] text[plot_01.xlab] viewport[plot_01.ylab.vp] text[plot_01.ylab]
xyplot(mpg ~ disp, mtcars) grid.edit("plot_01.ylab", rot=0)
R -> SVG
library(gridSVG) xyplot(mpg ~ disp, mtcars) grid.export("svg-plot.svg")
<svg> <rect id="plot_01.background.1.1"/> <g id="plot_01.toplevel.vp.1"> <g id="plot_01.xlab.vp.1"> <text id="plot_01.xlab.1"> disp </text> ...
xyplot(mpg ~ disp, mtcars) grid.garnish("plot_01.xyplot.points.panel.1.1", title=rownames(mtcars)) grid.export("svg-plot.svg")
SVG -> R
library(XML) svg <- xmlParse("Multilingualism.svg") polys <- getNodeSet(svg, "//svg:polygon") invisible(lapply(polys[!retain], remove)) saveXML(svg, "Multilingualism-Auckland.svg")
It is important to remember to provide permission for others to use your graphic
versus ©
Reusable graphics are better than dead-end graphics
Choosing the right format is important
Adding mark up (labels and structure) is also important