Installing packages onto R

后端 未结 4 1219
广开言路
广开言路 2020-12-16 12:47

For some reason I am suddenly not able to install packages in R (I have subsequently updated to the latest version of R and am running Windows 7). For example, if I type:

4条回答
  •  一生所求
    2020-12-16 13:24

    I will probably duplicate a lot of other answers on the stackoverflow, but I got exactly the same error as OP, namely: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open compressed file 'zoo/DESCRIPTION', probable reason 'No such file or directory'

    Turned out, while I as a user had permissions to write in a certain directory, R did not. In order to be sure you don't have something similar, do following:

    1. get a usb drive, let's name it E
    2. download package source as a .zip file and store it onto usb-drive in some directory, let's name it E:/source
    3. Create directory for libraries on the usb drive, let's name it E:/libs
    4. Install packages calling R command install.package from the R console and setting all relevant directories to point to your usb drive:

      (here I use package zoo as an example)

      install.packages("E:/source/zoo_1.7-12.zip", 
                       destdir = 'E:/source',  # no "/" after the path
                       lib = 'E:/libs', 
                       repos = NULL)
      
    5. Load the package from the directory, where you installed it: library('zoo', lib.loc = 'E:/libs')


    After you are sure, it works this way on your usb drive, you can start resolving directories permissions, and try out by changing the paths in the code above.

    update: In some windows environments even your usb-stick might be protected from read-write by the R. Make sure you check the permissions using the machine you are working from.

提交回复
热议问题