file.remove after display...

18 views
Skip to first unread message

George Kumar

unread,
Dec 17, 2011, 3:47:42 AM12/17/11
to rapache
Forgive me if this has already been asked or I am making some silly
mistakes.

I was wondering what is wrong with this code.

....do some calculation ....
png(file=outputfile)
....call plot()...to produce a plot....
....
cat("<br>")
img(imgoutfile); <<<<<<this is just an R function that produces
html <img> tag...
cat("</BODY></HTML>\n")
file.remove(outputfile)- <<<<<< Putting this causes problem......
DONE

My goal was to remove the file on the server once it is displayed on
the browser...but as soon as I introduce file.remove() line....the
file is indeed deleted on the server..but the image is not displayed
at all..instead all I see is a broken sign...where an Image should
have been...

Is there anything wrong with this code sequence..?

Thanks all.
George

Aleksandar Blagotić

unread,
Dec 17, 2011, 5:56:33 PM12/17/11
to rap...@googlegroups.com
Use tempfile().

aL3xa



George

--
You received this message because you are subscribed to the Google Groups "rapache" group.
To post to this group, send email to rap...@googlegroups.com.
To unsubscribe from this group, send email to rapache+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rapache?hl=en.


George Kumar

unread,
Dec 19, 2011, 12:13:22 AM12/19/11
to rapache
tempfile() has the same issue. Notice that I am not using sendBin,
readbin combination that are given as examples in the file
rapache-1.1.9/test/sendBin.R. I am using my own function, the code for
which is shown below. Basically it just inserts a html href tag in the
file to display the image:

img <- function (src)
{
result <- src
result <- paste("<IMG SRC=\"", result,
"?nocache=", sample(9999, 1), "\"",
sep = "")
result <- paste(result, ">", sep = "")
cat(result)
invisible(result)
}

Thanks.
George

On Dec 17, 2:56 pm, Aleksandar Blagotić <aca.blago...@gmail.com>
wrote:

Christian Parker

unread,
Dec 19, 2011, 1:19:48 AM12/19/11
to rap...@googlegroups.com
I may be wrong but I believe that all of the R code is processed by
the server before the HTML code is passed along, which means your
image is deleted by the time the browser knows to look for it.
Reply all
Reply to author
Forward
0 new messages