[R] tempfile problem

jim holtman jholtman at gmail.com
Thu Jun 17 18:49:05 CEST 2010


take the name returned by tempfile and append the current TOD; this
should make it fairly unique and will let you do some cleanup if you
are going to keep the files around for some length of time.

On Thu, Jun 17, 2010 at 12:43 PM, Ben Madin
<lists at remoteinformation.com.au> wrote:
> G'day all,
>
> The documentation for tempfile states :
>
> "The names are very likely to be unique among calls to tempfile in an R session and across simultaneous R sessions. The filenames are guaranteed not to be currently in use."
>
> My problem I think relates to the second part of the sentence, which is the guarantee... and it is being met ... but I need to save the files as .png files, in the same directory, so I am adding the suffix and I suppose therefore the next offering can be unique (as it doesn't have the prefix)
>
> I am using a command like :
>
>> fname <- basename(tempfile("nahis", "/Library/WebServer/Documents/nahis/tmp"))
>
>  on a mac, or
>
>> fname <- basename(tempfile("nahis", "/htdocs/nahis/tmp"))
>
> on a FreeBSD system, as I need to be able to find the file from the web browser up to 24 hours later.
>
> and then
>
>> this_filename <- paste(fname, ".png", sep = "")
>
> and saving the file as this_filename, hence the next call doesn't find it's own suggestion, and starts again.
>
> Is there any alternative filenameing approach I can use to get around this? Do I need to manually scan and reject the name if it matches the names I already have? Should I just digest the current time ? (It's working so far!)
>
> cheers
>
> Ben
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list