R2HTML cannot open connection

I am creating a repeating HTML report displaying tables and graphs computed using R. I am using functions from the R2HTML package built into the for loop. I do not have administrator rights on my machine. At some point in the calculations, I sometimes get the following error:

Error in file (file, ifelse (append, "a", "w")): cannot open the connection. Also: Warning message: In file (file, ifelse (append, "a", "w")): not can open the file "P: / My Documents /R/test.html": Permission denied

This does not happen at every start, or at the same point in the code. I can get the same error when I try to run the following simple code:

require( R2HTML) .HTML.file = file.path( 'P:/My Documents/R' , 'test.html' ) # To set the access path to the HTML file that will be created cat(paste("<html><head><title>", 'test.html', "</title></head>", sep = ""), file = .HTML.file , append = FALSE ) # To create and initiate the HTML file for( i in 1:100 ) { HTML('Test') } # To write the same line to the HTML file repeteadly 

In most cases, this cycle can start without any problems, but sometimes it causes an error above (sometimes at the beginning of the cycle, sometimes at the end). Does anyone know what causes this? I am using R-2.15.0 on a Windows xp pro computer. If anyone can help me, I will be very kind. Thanks.

+1
source share
1 answer

As Andri suggested in the comments, the solution is to capture the output of the R2HTML functions in string objects and use only one call to the HTML function to create the HTML file after the loop.

0
source

All Articles