Compatibility for Non-CRAN Source Packages [duplicate] - r

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

Installation of R on redhat8 offline

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

install cnv-seq.tar.gz in R

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.

installing package from a local .tar.gz file on Linux [duplicate]

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.

R install Vennerable package on windows [duplicate]

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

How do I install an R package from the source tarball on windows?

The forecast package for R has been updated to version 2.12, but there are currently only windows binarys for 2.11 available on CRAN.
How do I install an R package from the source on Windows?
I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:
Install rtools, then:
install.packages(path_to_file, repos = NULL, type="source")
Two answers that may help you avoid the hassle of installing Rtools.
Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.
I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.
I'm not sure if this is the best way, but I found the following method to work (based in part on the answers above):
1) Download the package .tar
2) Move the package to the directory with your user R libraries (e.g., in my case it was "C:/Users/yourUserName/Documents/R/win-library/3.3")
3) Within Rstudio (or elsewhere, probably), run the command... install.packages("packageName.tar", repos=NULL, type="source")
That worked for me at least. Hope it's helpful!
Download the package *.tar.gz.
make sure you have Rtools installed.
Make sure the R and Rtools paths are added in the environment varialble.
Open a command prompt. Type R CMD INSTALL packagename.tar.gz.
it will work i hope.
To install a package from a .tar.gz file, follow these steps:
Launch R to have the R command prompt
Type: install.packages(<path_to_tar.gz_file>, repos = NULL)
or launch directly:
R CMD INSTALL <path_to_.tar.gz_file>
You need to have R installed but you don't need RTools

Resources