4

I solved the problem by moving R installation directory out of disk C. Thanks Joris for the great suggestions! I think the R core team should also take this as a bug and do something against the protecting mechanism of windows xp.

Dear Community:

While using the BIOMOD packages in R, I always get the following problem:

Error in xzfile(file, "wb", compression = 9) : cannot open the connection In addition: Warning message: In xzfile(file, "wb", compression = 9) : cannot initialize lzma encoder, error 5

It was said by the author of the package and also in the help file of "save" that the problem should be caused by lack of permission to write. However, as I am logging in as administative account and have assess to all operations, I have no idea what the problem is. Can anybody help me out? I really need to run the package now. Thanks in advance~

Sincerely, Marco

Below is the illustration in the help file of "save":

The most common reason for failure is lack of write permission in the current directory. For 'save.image' and for saving at the end of a session this will shown by messages like

    Error in gzfile(file, "wb") : unable to open connection
     In addition: Warning message:
     In gzfile(file, "wb") :
       cannot open compressed file '.RDataTmp',
       probable reason 'Permission denied'
 The defaults were changed to use compressed saves for 'save' in
 2.3.0 and for 'save.image' in 2.4.0.  Any recent version of R can
 read compressed save files, and a compressed file can be
 uncompressed (by 'gzip -d') for use with very old versions of R.*

Sorry for the ommision of the information: Here is the sessionInfo():

> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Chinese_People's Republic of China.936 
[2] LC_CTYPE=Chinese_People's Republic of China.936   
[3] LC_MONETARY=Chinese_People's Republic of China.936
[4] LC_NUMERIC=C                                      
[5] LC_TIME=Chinese_People's Republic of China.936    

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] BIOMOD_1.1-6.8     foreign_0.8-42     gam_1.04          
 [4] randomForest_4.6-2 mda_0.4-1          class_7.3-3       
 [7] gbm_1.6-3.1        lattice_0.19-17    MASS_7.3-11       
[10] Design_2.3-0       Hmisc_3.8-3        survival_2.36-5   
[13] rpart_3.1-48       nnet_7.3-1         ade4_1.4-16       
[16] rgdal_0.6-33       dismo_0.5-19       rJava_0.9-0       
[19] raster_1.7-47      sp_0.9-78         

    loaded via a namespace (and not attached):
    [1] cluster_1.13.3 grid_2.12.2    tools_2.12.2 

Now I found that the problem come form the lzma encoder in doing "save":

>  x<-runif(100)
>  save(x, file = "F:/test.gzip", compress='gzip')
>  save(x, file = "F:/test.xz", compress='xz')
Error in xzfile(file, "wb", compression = 9) : cannot open the connection
> 
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
Marco
  • 505
  • 9
  • 18
  • Are you on a Windows or Unix based system? – Ryan Castillo Mar 01 '11 at 02:00
  • what version of R and what version of BIOMOD, and where is that package from? use sessionInfo() for a version summary – mdsumner Mar 01 '11 at 02:33
  • 1
    Where exactly did you save your R version, and which version of Windows do you have? You can try to run R as administrator (which is not the same as run R in an account with administrator rights) or NOT install R in the folder Program Files. Problem might be there, as it's a protected folder under Windows. From the error, it seems like the temporary file cannot be read. – Joris Meys Mar 01 '11 at 12:19
  • It is not a bug for the R-core team to worry about. If you run R as an administrator, you have all the rights you need, but I advice against it. You can do a lot of harm to your system if you're not careful. – Joris Meys Mar 02 '11 at 12:18
  • Yes, you are right, the protection mechanisms in windows should not be a concern for R, however, at least, there should be more illustration about this lack of permission. It is crazy that, after only one day, I have the problem again now. And, right now, the R dir is outside of disk C. This really drove me crazy~~~~ – Marco Mar 03 '11 at 02:57
  • @Marco: if you have solved the problem, you could give the solution as an answer and then accept it. Doing that would avoid this question appearing in the unanswered list. – Henry Apr 13 '11 at 01:38

1 Answers1

-2

I had a similar issue when trying to project to a new scenario (a tables containing columns corresponding to the predictor variables) after having run the modeling procedure using 8 models.

The first table (approx 250,000 rows) ran fine, and I was able to save the results as a .csv file. However the second one (approx 380,000 rows) resulted in the above error message, and some of the files were not written to the project folder.

I have since cut all the tables down to a maximum of 260,000 rows and I no longer recieve the error message. It was a bit of a pain doing it in multiple runs, but once I had written the script once, I just used find and replace in MS Word to change it for each run.

jonsca
  • 10,218
  • 26
  • 54
  • 62
  • 4
    I'm down-voting because of the suggestion to use MS-Word for editing anything to do with R data. That is a source of confusing error and frustration. – IRTFM Aug 31 '12 at 20:37