Re: [R] Tempfile error

From: Doran, Harold <>
Date: Fri 08 Jul 2005 - 00:46:06 EST

Dear Uwe and Sean:

Thank you for your reply. I think I did a poor job framing my problem. Here are a few things I should have added. First, I previously stated that the program would halt in random places. This is *not* true. It always halts at the same row, which happens to be row 1038. There isn't a logical reason for stopping in this row as far as I can tell, all data needed to generate the file are present.

I am using R version 2.10 for Windows on an XP machine with 2 gb ram. My tex distribution is MikTex (I'm not sure if that matters).

Traceback gives the following information

> traceback()

9: file()
8: driver$runcode(drobj, chunk, chunkopts)
7: Sweave("fam_template.Rnw", output = tmp2)
6: eval.with.vis(expr, envir, enclos)
5: eval.with.vis(ei, envir)
4: source("run_fam.r")
3: eval.with.vis(expr, envir, enclos)
2: eval.with.vis(ei, envir)
1: source(file.choose())

I did tempfile() to identify the location of the files and have cleaned that out repeatedly. I've searched the archives and have seen some discussion regarding and on.exit() command, but I'm not sure I see how it would be utilized here.

Here is the code for the looping file that subsets the dataframe. I wonder if I need to add something here that would close a connection or generate a random tempfile name to avoid this problem in the loop.

list <- unique(wide$stuid)
master = "master.tex"
for (i in list){

     tmp1 <- subset(wide, stuid==i)
     tmp2 <- paste(i, "tex", sep=".")
     Sweave("fam_template.Rnw", output=tmp2)
     file.append("fam_master.tex", tmp2)     

Thanks for your time on this,

-----Original Message-----
From: Uwe Ligges [] Sent: Thursday, July 07, 2005 4:52 AM
To: Doran, Harold
Subject: Re: [R] Tempfile error

Doran, Harold wrote:

> Dear List:
> I am encountering an error that I can't resolve. I'm looping through
> rows of a dataframe to generate individual tex files using Sweave. At
> random points along the way, I encounter the following error
> Error in file() : cannot find unused tempfile name

Which version of R is this?
I think during one of the latest releases tempfile() name generation has been imporved, because R did not tried hard enough to find new (random) filenames for tempfiles in older releases of R.

Uwe Ligges

> At which point Sweave halts. There isn't a logical pattern that I can
> identify in terms of why the program stops at certain points. It just
> seems to be random as far as I can tell. I've searched the archives
> and of course Sweave FAQs but haven't found much that sheds light on
> what this error indicates and what I should do to resolve it.
> There are approximately 20,000 rows, meaning that about 20,000 tex
> files are created. If I sample 5,000 or even 10,000 and run the
> program, I do not encounter an error. It only occurs when I run the
> program on the full dataframe and even then the error is not occuring
> at the same point. That is, the row at which the program halts varies
each time.
> Does anyone have any thoughts on this problem?
> -Harold
> [[alternative HTML version deleted]]
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!
> mailing list PLEASE do read the posting guide! Received on Fri Jul 08 00:56:23 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:20 EST