Reputation: 193
I don't have access to internet. Hence, i downloaded sqldf package from other system and then transfer it to this system.
The sqldf_0.4-10.tar file is saved in "C:\Users\Riya\Documents\R" and also saved binary file in the same folder. I want to install the package with dependencies as well. When i am installing the package using "Install Package from local zip file" under "Packages" dropwdown. It is not installing dependencies. I googled solutions and found :
tools::write_PACKAGES("C:/Users/Riya/Documents/R/")
After that,
install.packages("sqldf", repos="file://C:/Users/Riya/Documents/R/")
It 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's a window system.
Note : tools::write_PACKAGES()
creates 2 files. I also deleted "PACKAGES.gz" file as per the solution mentioned in a forum.
Upvotes: 3
Views: 2757
Reputation: 1
Installing multiple packages from local zip files in R [ Windows 7 32 bit and RGui(32bit) i386 3.3.0 ]
*i am not use to in R, even Stack.
In simple way we do ---
Run following R commands
install.packages(file.choose(), repos=NULL)
file.choose()
command will show a window allowing you to choose the .zip
file or the tar.gz
file where you downloaded it.Now we try to installing multiple packages form local drive ---
In R Console run following commands -
result <- array(list.files(path = "D:/Backup/R tutorial/downloaded_packages", pattern = "*.zip", all.files = FALSE, full.names = FALSE, recursive = FALSE))
result
store the the list of zip files name in array until the value replace by any way or close the RGui (work space).path = "..."
replace your own drive path.pattern = "..."
may replace "tar.gz"
but i did not test it yet.Now run the 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")
}
x
we store the file name, paste
help me to do that.install.packages(x, repos = NULL, type = "win.binary")
installing the zip file(s) one by one.readline
take input from a user to continue the loop. Here i comment it by #
Normal loop execution -
[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'
print(i)
show the number of array read e.g. [1] 7403
print(result[i])
show the zip file e.g. [1] "RKEELjars_1.0.15.zip"
now manually download and replace the zip file and change in loop
for(i in 1:length(result))
by for(i in 7403:length(result))
and re run the
program again e.g.
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")
}
Upvotes: -1
Reputation: 16727
From the R console you can go with:
install.packages("C:/Users/Riya/Documents/R/sqldf_0.4-10.tar", repos=NULL, type="source")
You can also install from OS command line, using R CMD INSTALL as G. Grothendieck wrote in the comment.
Upvotes: 4