[R] R crashes using pdf() windows() or postscript()

From: Jan Wijffels <Jan.Wijffels_at_ucs.kuleuven.be>
Date: Tue 01 Aug 2006 - 17:43:50 EST

Dear HelpeRs,
I have a script where I save several thousands of graphics. These are then used in Latex through Sweave. Unfortunately R crashes while making these plots and Windows pops up some message that I run low on virtual memory. I tried to save the plots using pdf(), windows() and postscript() and also tried to run it with R CMD BATCH myscript.R. But after a while R slows down and crashes eventually or stops computing. I'm using windows XP with R 2.3.1. I included a script that shows the
problem if you let it run for a while.
> R.version

platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
major          2
minor          3.1
year           2006
month          06
day            01
svn rev        38247
language       R

version.string Version 2.3.1 (2006-06-01)    

draw.rectangle <- function(

     box.gpar=gpar(fill=rgb(red=51, green=51, blue=204, maxColorValue =
                   col=rgb(red=128, green=128, blue=128, maxColorValue =
     text.gpar=gpar(col="white", fontface="bold", fontsize=14, cex=1,
     type="pdf") {

   if(type == "win"){
     windows(width=1.4, height=0.5)
   else if(type == "pdf"){
     pdf(file = paste(figurename, ".pdf", sep=''), width = 1.4, height = 0.5, onefile = TRUE, family = "Helvetica", paper = "special")

   else if(type == "ps"){
     postscript(file = paste(figurename, ".ps", sep=''), width = 1.4, height = 0.5, onefile = TRUE, family = "Helvetica", paper = "special", fonts = "sans")

   boxheight <- unit(1, "npc")
   boxwidth <- unit(1, "npc")
   pushViewport(viewport(x=0.5, y=0.5, width = boxwidth, height = boxheight))

     grid.roundRect(height=boxheight, width=boxwidth, r=unit(3, "mm"), gp = box.gpar)

     grid.text(label, just = "centre", gp = text.gpar)    popViewport()
   if(type == "win"){
     tmp <- savePlot(filename = figurename, type = "pdf", device = dev.cur(), restoreConsole = TRUE)

   tmp <- dev.off()
for(i in 1:10000){

   draw.rectangle("blablabla", type="win") }  

Anyone has suggestions on how to solve this?    


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

        [[alternative HTML version deleted]]

R-help@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 Aug 01 17:49:45 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 03 Aug 2006 - 14:19:38 EST.

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