R from local disk

I have no internet access. Hence, I downloaded the sqldf package from another system and then transferred it to that system.

The sqldf_0.4-10.tar file is saved in "C: \ Users \ Riya \ Documents \ R" and the binary is also saved in the same folder. I also want to install a package with dependencies. When I install a package using "Install package from local zip file" in the "Packages" dropdown. It doesn't install dependencies. I googled solutions and found:

tools::write_PACKAGES("C:/Users/Riya/Documents/R/") 

      

Thereafter

install.packages("sqldf", repos="file://C:/Users/Riya/Documents/R/") 

      

This is giving me an error -

source repository is unavailable to check versions 
Error in read.dcf(file = tmpf) : cannot open the connection 
In addition: Warning message: 
In read.dcf(file = tmpf) : 
cannot open compressed file '//C:/Users/Riya/Documents/R/bin/windows/contrib/3.1/PACKAGES', probable reason 'No such file or directory'> 

      

It is a window system. Note: tools::write_PACKAGES()

Creates 2 files. I also deleted the "PACKAGES.gz" file according to the solution mentioned on the forum.

+3


source to share


2 answers


From the R console, you can go:

install.packages("C:/Users/Riya/Documents/R/sqldf_0.4-10.tar", repos=NULL, type="source")

      



You can also install from the OS command line using the R CMD INSTALL as G. Grothendieck wrote in a comment.

+4


source


Installing multiple packages from local zip files in R [Windows 7 32 bit and RGui (32 bit) i386 3.3.0]

* I don't use R, not even Stack.

In a simple way we do ---



  • Download the zip file of the package, save it to your local drive.
  • Run the following R commands

    install.packages(file.choose(), repos=NULL)
    
          

    • The command file.choose()

      will show a window where you can select the file .zip

      or file tar.gz

      you uploaded it to.

Now we are trying to install some packages from local disk ---

  • Download the zip file of the package, save it to your local drive.
  • Open RGui i386 3.3.0.
  • In the R Console, run the following commands:

    result <- array(list.files(path = "D:/Backup/R tutorial/downloaded_packages", pattern = "*.zip", all.files = FALSE, full.names = FALSE, recursive = FALSE))
    
          

    • result

      keep a list of zip file names in an array until the value is replaced in some way or exits RGui (workspace).
    • path = "..."

      replace your own drive path.
    • pattern = "..."

      might replace "tar.gz"

      , but I haven't tested it yet.
  • Now run a loop to install all zip files:

    for(i in 1:length(result)) {
      x <- paste("D:/Backup/R tutorial/downloaded_packages/",result[i], sep="", collapse = NULL)
      print(i)
      print(result[i])
      install.packages(x, repos = NULL, type = "win.binary")
      # readline(prompt="Press [enter] to continue")
    }
    
          

    • In x

      we save the filename, paste

      help me to do this.
    • install.packages(x, repos = NULL, type = "win.binary")

      installing zip file (s) one by one.
    • readline

      accepts a request from the user to continue the loop. Here I will comment on it#

  • Performing a normal cycle -

    [1] 7402   
    [1] "RKEELdata_1.0.3.zip"
    Installing package into β€˜C:/Users/Amitava Kar/Documents/R/win-library/3.3’
    (as β€˜lib’ is unspecified)
    
          

  • Common error and exit loop -

    [1] 7403
    [1] "RKEELjars_1.0.15.zip"
    Installing package into β€˜C:/Users/Amitava Kar/Documents/R/win-library/3.3’
    (as β€˜lib’ is unspecified)
    Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : 
      cannot open the connection
    In addition: 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 'RKEELjars/DESCRIPTION', probable reason 'No such file or directory'
    
          

    • This error shows when the zip file is corrupted or unreadable.
    • print(i)

      shows the number of arrays read, eg. [1] 7403

    • print(result[i])

      shows a zip file eg. [1] "RKEELjars_1.0.15.zip"

    • now manually download and replace the zip file and change in a loop for(i in 1:length(result))

      to for(i in 7403:length(result))

      and run again, for example

      for(i in 7403:length(result)) {
      x <- paste("D:/Backup/R tutorial/downloaded_packages/",result[i], sep="", collapse = NULL)
      print(i)
      print(result[i])
      install.packages(x, repos = NULL, type = "win.binary")
      # readline(prompt="Press [enter] to continue")
      }
      
            

-1


source







All Articles