This question already has answers here:
How do I install an R package from source?
(7 answers)
Closed 6 years ago.
I would like to install the plyr package from a .tar.gz file, into my library of R packages on a linux machine. How would I go about doing this? Do I just place it in the library directory? What if I do not have write permissions?
In the command line:
R CMD INSTALL <package-name>.tar.gz
Or in R:
install.packages(<pathtopackage>, repos = NULL, type="source")
From the command line,
R CMD INSTALL plyr_x.y.z.tar.gz
If you don't have permission to write to the standard library directory and can't use sudo to override, you can install it somewhere else via
R CMD INSTALL -l <user_lib> plyr_x.y.z.tar.gz
where <user_lib> is a directory you can write to. You may need to specify lib.loc when subsequently loading the package, if <user_lib> is not in .libPaths (see #DWin's answer).
See http://cran.r-project.org/doc/manuals/R-admin.html for more information; R CMD INSTALL --help may also be useful, albeit terse.
If you do not have permissions to the default installed library you can add to the search path that R uses with .libPaths which "gets/sets the library trees within which packages are looked for."
.libPaths() # will display all current libraries
?.libPaths
The second argument to install.packages (after the name of your plyr.version.tar.gz file) could be a user-controlled library directory.
?install.packages
I was a bit puzzled by first asking about installing from CRAN and then asking about installing a tar.gz file from which I formed the impression that you had already downloaded the file and were hoping to install it.
Related
I'm trying to have a way to download R for multiple clients with no internet access. Is there a way to download the .tar.gz files for all of R and its dependencies, so you don't need to download with internet connection? If there is a way to do that will R still show up with the "whereis R" command on linux? I'm trying to find a way in which I can give someone the downloaded files already within a package and they just run a .sh script that will download everything and R's dependencies for them with no real user intervention.
You may follow the manual on the topic "installing R under Unix-alike". Briefly: download the source and make it.
Download R and untar it
You can download the source from:
https://cran.r-project.org/sources.html
Then, use "tar" to extract the source and build it. Let's suppose that you want to install R 4.2:
tar -xf R-4.2.0.tar.gz
Make
Go to a directory where you will install R. Note that the path shouldn't contain spaces.
./configure
make
make check
If you want to install all the R tree (binaries, manuals, libraries...) use:
make install
Installing packages from source
To install packages in R, you can use the function install.packages() with the name of the file ('...tar.gz') to be installed and the argument "repos" set as "NULL"
You can also install the packages from a shell:
R CMD INSTALL -l /path/to/library packagename
Check the manual for additional information
You may also be interested in looking at this information:
https://cran.r-project.org/bin/linux/redhat/
https://cran.r-project.org/sources.html
The R manual describes how to install R from source in:
R-admin > Obtaining R > Getting and unpacking the sources
R-admin > Installing R under Unix-alikes
For reasons that are too long to explain here, I must use R.2.8.1 (unfortunately). I need to have the xlsx package installed on it. Since I am on R 2.8.1, about ten years old, I can't use the latest version of xlsx but an older version, for instance xlsx_0.1.3 from 2010 seems a good choice. However the previous releases per R-CRAN policy are only available in tar.gz.
This is very unfortunate to me because I have to use RGui on windows which only accepts .Zip packages in installation. Therefore I tried the following stuff, in vain:
1-I tried to use Rcmd but I get the following error message:
C:\Program Files (x86)\R\R-2.8.1\bin>Rcmd INSTALL C:\Users\username\Downloads\xlsx_0.1.3.tar.gz
Can't use 'defined(#array)' (Maybe you should just omit the defined()?) at C:\PROGRA~2\R\R-28~1.1/bin/INSTALL line 42.
so I give up on this one.
2-Then I think that the best solution is to convert the package xlsx_0.1.3.tar.gz into a compatible xlsx_0.1.3.zip package by building it using R.2.8.1 but I can't make it. Here is one of the things I have tried so far.
I have unziped xlsx_0.1.3.tar.gz and I organized it in the following way, which brought me the furthest:
Documents\xlsx
Documents\xlsx\activate.bat
Documents\xlsx\build_xlsx.bat
Documents\xlsx\R
Documents\xlsx\R\inst
Documents\xlsx\R\man
Documents\xlsx\R\other
Documents\xlsx\R\R
Documents\xlsx\R\DESCRIPTION
Documents\xlsx\R\NAMESPACE
Documents\xlsx\R\NEWS
Documents\xlsx\R\WISHLIST
inside activate.bat, I wrote:
SET TMP=C:\Users\username\Documents\TOTO\xlsx\tmp
SET TEMP=%TMP%
SET RTOOLSPATH=C:\DEV_307\toto\Rtools
SET RPATH=C:\DEV\toto\R\R-2.8.1
SET PATH=%RTOOLSPATH%\bin;%RTOOLSPATH%\MinGW\bin;%RPATH%\bin;%PATH%
inside build_xlsx.bat, I wrote:
R CMD BUILD R
R CMD check --no-examples --no-tests R
R CMD build --docs=normal --binary R
Then I still get:
C:\Users\username\Documents\TOTO\xlsx>R CMD BUILD R
* checking for file 'R/DESCRIPTION' ... OK
* preparing 'R':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
Can't use 'defined(#array)' (Maybe you should just omit the defined()?) at C:\DEV\toto\R\R-2.8.1/bin/INSTALL line 42.
ERROR
Installation failed.
Removing 'C:/Users/username/Documents/Rinst1210839349'
Thank you for your help
I can't include structured content in comments. This is really a comment.
The structure of source packages (which is what you have with xlsx_0.1.3.tar.gz if you pulled it from the CRAN archives) hasn't changed (much) since 2.8.1.
You'll also need to grab rJava_0.8-3.tar.gz and xlsxjars_0.2.0.tar.gz from the archive as xlsxjars + xlsx rely on rJava.
Extract each (since Windows R 2.8.1 seems to not grok gz files). They should make rJava, xlsxjars and xlsx directories each.
Move to the parent directory of both.
Run:
R CMD javareconf
R CMD build rJava
R CMD INSTALL rJava_0.8-3.zip # I believe this will be the name
R CMD build xlsxjars
R CMD INSTALL xlsxjars_0.2.0.zip
R CMD build xlsx
R CMD INSTALL xlsx_0.1.3.zip
and you should be gtg.
This question already has answers here:
How do I install an R package from source?
(7 answers)
Closed 6 years ago.
I would like to install the plyr package from a .tar.gz file, into my library of R packages on a linux machine. How would I go about doing this? Do I just place it in the library directory? What if I do not have write permissions?
In the command line:
R CMD INSTALL <package-name>.tar.gz
Or in R:
install.packages(<pathtopackage>, repos = NULL, type="source")
From the command line,
R CMD INSTALL plyr_x.y.z.tar.gz
If you don't have permission to write to the standard library directory and can't use sudo to override, you can install it somewhere else via
R CMD INSTALL -l <user_lib> plyr_x.y.z.tar.gz
where <user_lib> is a directory you can write to. You may need to specify lib.loc when subsequently loading the package, if <user_lib> is not in .libPaths (see #DWin's answer).
See http://cran.r-project.org/doc/manuals/R-admin.html for more information; R CMD INSTALL --help may also be useful, albeit terse.
If you do not have permissions to the default installed library you can add to the search path that R uses with .libPaths which "gets/sets the library trees within which packages are looked for."
.libPaths() # will display all current libraries
?.libPaths
The second argument to install.packages (after the name of your plyr.version.tar.gz file) could be a user-controlled library directory.
?install.packages
I was a bit puzzled by first asking about installing from CRAN and then asking about installing a tar.gz file from which I formed the impression that you had already downloaded the file and were hoping to install it.
I'm trying to install this cnv-seq package on my R library to help copying number variation analysis. However, when I type in
install.packages("cnv-seq")
in R command, an error code pops out saying it is not available for 3.1.1 version. So I tried the old versions as well. All says not available. And I double check with the menu, Packages-> Install packages->. No cnv-seq
Ok. Then I tried to install it from a local source which is the "cnv-seq.tar.gz"
when i type in
install.packages("C:/cnv-seq.tar.gz", repos=NULL, type="source")
it still returns an error that says cannot extract package from this file.
Installation of package had non-zero exit status.
Anything went wrong or is there another I can install this package manually to my PC? After take a look at a similar question here couple years ago,
How do I install an R package from source?
I still could not fix this problem.
This is a case of RTFM ;)
You can do the whole process from within R. Below, we download the archive to the temporary directory, then extract it and finally install it.
download.file('http://tiger.dbs.nus.edu.sg/cnv-seq/cnv-seq.tar.gz',
f <- tempfile())
untar(f, exdir=tempdir())
install.packages(file.path(tempdir(), 'cnv-seq', 'cnv'), type='source', repos=NULL)
I believe you first must untar the file. I believe 7zip has this capability if you do not have access to a linux machine. The linux command would be:
tar -xvf /path/to/file/cnv-seq.tar.gz
After you do this you should be able to import the package into R.
This question already has answers here:
Cannot install R-forge package using install.packages
(4 answers)
Closed 8 years ago.
I am not able to install the Vennerable R package from https://r-forge.r-project.org/projects/vennerable/ on my Windows 7 with newest R (2.13.0).
I tried following:
installed from RGui and selecting R-Forge repos:
there was no Vennerable package in the list
installed from RGui using "install package from local zip file":
can not open compressed file 'Vennerable.tar.gz/DESCRIPTION'
converted tar.gz into zip and installed from RGui using "install package from local zip file":
can not open compressed file 'Vennerable.tar.gz/DESCRIPTION'
tried manual install: install.packages("D:/Downloads/Vennerable.tar.gz", repos = NULL)
can not open compressed file 'Vennerable.tar.gz/DESCRIPTION'
Error in install.packages : cannot open the connection
Note: there is a file DESCRIPTION.
What should I do to install this package?
Links on package page are dead (to either Windows build and package source).
You can checkout the source: open the terminal and run the following command
svn checkout svn://svn.r-forge.r-project.org/svnroot/vennerable
Then build without vignettes.
cd vennerable/pkg
R CMD build Vennerable/ --no-build-vignettes
and finally to install it:
R CMD INSTALL Vennerable_3.0.tar.gz
(Your build might be in a different name than Vennerable_3.0.tar.gz).
For me it generated the following error:
ERROR: dependencies ‘graph’, ‘RBGL’, ‘xtable’ are not available for package ‘Vennerable’
Then I had to go to R, run the following command:
install.packages(c("graph", "RBGL", "xtable"))
and then go back to the terminal and run the R CMD INSTALL ... command again.
Vennerable package has been updated and now version 2.1 is available from R-forge using
install.packages("Vennerable", repos="http://R-Forge.R-project.org")
I had the same problem and figured it out. The issue was with how the package is archived. There is a directory called 'Vennerable' within the top level directory which is called "Vennerable_2.2'. I unzipped the archive. Then I navigated to the 'Vennerable' subdirectory, and zipped that. Then I ran the installation using the new 'Vennerable.zip' archive. Worked like a charm.
If you have a tar.gz archive, you likely have the package's source files. You must build it first before installing the package. See section 1.3 of the Writing R Extensions manual
See also your other related question, where I provided this link to the built package for R 2.13.0 x86_64:
http://commondatastorage.googleapis.com/jthetzel-public/Vennerable_1.1.1.1.zip