I recently began using RStudio on a Linux system (Ubuntu 20.4) after having used it exclusively on Windows. I realized pretty quickly that a major difference between the two is that R will automatically locate and download non-R dependencies on Windows, but will not do so on Linux. Searching for the dependencies of any given package is easy enough and I'm comfortable with downloading non-R packages through the terminal. What I'm still struggling with, though, is identifying which packages are R packages and which packages are non-R packages and I haven't found a thread that outlines how to do this. I could certainly spend some time googling each, but, as an example, ggpubr alone has over 95 dependent packages that it uses. How can I efficiently determine which non-R dependencies a package needs?
You need to read the DESCRIPTION file. It has a free-form field called SystemRequirements that describes non-standard requirements of the package.
You can see this on the CRAN page, or use the utils::packageDescription() function to see it if you can get the package installed. For example,
cat(utils::packageDescription("rgl")$SystemRequirements)
#> OpenGL, GLU Library, XQuartz (on OSX),
#> zlib (optional), libpng (>=1.2.9, optional), FreeType (optional),
#> pandoc (>=1.14, needed for vignettes; if not present,
#> markdown package will be used)
Created on 2022-04-16 by the reprex package (v2.0.1)
On CRAN this is shown on https://cloud.r-project.org/web/packages/rgl/index.html .
Many packages test for their dependencies and try to give helpful messages about how to install their dependencies if they aren't found. Others just fail to install, sometimes with fairly inscrutable error messages.
The reason this can be easier on Windows is that binary versions of packages are available for Windows. The nice people at CRAN find and install a large number of system dependencies on their own systems, then use those to build binary versions of the package that statically link the required libs. However, some packages can't statically link; they need DLLs of the libs to be installed on the system. Those ones can be quite hard for Windows users to install.
Related
This question already has answers here:
R: apt-get install r-cran-foo vs. install.packages("foo")
(2 answers)
Closed 7 years ago.
In Debian, there are some compiled R packages in the official repositories. But one could also install a R package from source.
I am interested to know why would a user prefer one method of installation to another.
It's sometimes preferable to 'compile' the sources on your server rather than just using an existing executable file.
This is because the compiler makes the exe file specifically for your machine so may run faster and work much better, for instance the compiler knows the processor you have so can optimise for this.
I already provided a somewhat detailed answer in response to this SO question.
As an update, these days you even have lots of packages prebuilt thanks to updated cran2deb initiaives:
On Ubuntu you now have almost all CRAN packages prebuilt via Michael Rutter's 'cran2deb for ubuntu' ppa on Launchpad.
For Debian, Don Armstrong now provides a similar service (also covering BioConductor and OmegaHat) at debian-r.debian.net.
The idea of pre-compiled R packages for Debian/Ubuntu is borrowing from Windows and MacOS. Those OSes have pre-compiled packages since they typically don't have the standard tools in standard locations for building packages from source (c and fortran compilers, latex, perl, etc.).
If there is a new release of a package on CRAN, is the pre-compiled package on Debian repos automatically updated? I believe that you better sync with CRAN. Check out the package ctv to help you manage large collections of R packages ("CRAN views"), both for installing and updating.
You need root privileges to install a pre-compiled package from the OS repos, while any regular user may install any packages using install.packages() in R (but I recommend to run sudo R, if you are the sysadmin, for installing CRAN views, so as to make them available system-wide, instead of inflating your ~/).
One inconvenient to source packages is that if you fetch many, the compiling will take extra time to install (depending on your machine). You might gain in performance from compiling, but it is not guaranteed to be noticeable.
I have a code to track objects in the images. This code uses few function from the package clue. So clue is already installed in my system. Now I have created a package using the same code.
My description file has following lines.
Depends: R (>= 3.4.3),
clue
Because clue is already installed, I thought it will not get installed again when I use install("mypackage"). But to my surprise it re-installed the package. I have tried this with other installed packages, too. When I give it as "depends" or "import", it re-installs the packages. I do not want to re-install the packages if they are already on my system. Is there a way to tell R package installer to avoid re-installing packages that exist on the user's system? Some of these packages are quite large and take a lot of time to install. In addition, I have installed some packages with binary source/dependency that required me to give path for several libraries.
You can just use
install.packages(..., dependencies = FALSE)
or if you use devtools::install:
install(..., dependencies = FALSE)
I am currently running R on mac osx but am looking to purchase a linux server for more power. Is there any way that I can check for specific R packages whether they will also work on linux? (before, of course, I actually buy the server and try to install and run the given packages). Also, is there any way to determine if a given package would run on certain linux distributions but not others (e.g. Ubuntu vs. Debian)?
Assuming the package is on CRAN, go to the package's CRAN page, e.g. https://cran.r-project.org/package=zoo and then click on the link to the right of CRAN checks which in this example would be labelled zoo results. It would take you to this page: https://cran.r-project.org/web/checks/check_results_zoo.html showing the results of checking that package on various different platforms.
If the package is not on CRAN but is on github and the developer checks it with Travis-CI then you can view the check by clicking on the Travis-CI icon. For example, the klmr modules package is not on CRAN (there is a CRAN package of the same name but it's different); however, if you look at its github home page at https://github.com/klmr/modules and click on the icon which currently is black and green and reads build passing (but could read something else if there are changes to the package or R that breaks tests) then you will be taken to the Travis-CI tests at https://travis-ci.org/klmr/modules .
tl;dr Slightly opinion/personal experience based, but I would be surprised if there were any CRAN package that you couldn't get running on Linux.
In general Unix users tend to install packages from source: CRAN doesn't provide binaries, but source installation is usually painless. The package binaries that are available (the CRAN Linux page has links for Debian, Ubuntu, SUSE, and Red Hat) tend to focus on packages that have extra system-level dependencies (e.g. FFT libraries, or spatial data analysis libraries) where it's more of a nuisance to assemble the needed dependencies for a particular system.
From the CRAN repository policy:
Package authors should make all reasonable efforts to provide cross-platform portable code. Packages will not normally be accepted that do not run on at least two of the major R platforms [i.e. Windows, MacOS, Linux]. Cases for Windows-only packages will be considered, but CRAN may not be the most appropriate place to host them.
When a package fails to run on of one of the three platforms, it's usually Windows. The only package I've ever had real trouble installing on Linux is
R2OpenBUGS on 64-bit systems, because it requires installing a 32-bit toolchain.
When I install the packages in R, sometimes it is used by devtools::install_github(). other times it is used by install.packages().
Could I ask what is the essential difference between them?
R's official repository for packages is located on CRAN (Comprehensive R Archive Network). The process of publishing a package there is very strict and is reachable via install.packages(). For the most part, binary packages (opposed to source code, which is not "properly translated" yet) are available and no additional tools need to be present for proper installation (see next paragraph).
GitHub is one of many webservices that offers repositories for code, incl. R code. Author can upload her or his package and if everything is in its place, the user can install a package from source via devtools::install_github(). This means you need to have a proper toolchain installed (also a distributoin of LaTeX). In Windows, this means Rtools. Linux based OS are likely to be shipped with most of the necessary tools.
I was trying to run code that required the R packages ‘pkgDepTools’ and ‘Rgraphviz’. I received error messages saying that neither package is available for R version 2.15.0.
A Google search turned up the following webpage RPM Pbone that seems to have the packages:
http://rpm.pbone.net/index.php3/stat/4/idpl/17802118/dir/mandrake_other/com/R-pkgDepTools-1.20.0-1-mdv2012.0.i586.rpm.html
and
http://rpm.pbone.net/index.php3/stat/4/idpl/17802080/dir/mandrake_other/com/R-Rgraphviz-1.32.0-2-mdv2012.0.i586.rpm.html
However, the files have an *.rpm extension rather than the *.tar.gz or *.zip extensions I am used to.
I am using Windows 7 and R version 2.15.0. Can I install an R package from an *.rpm file?
From Wikipedia *.rpm seems like maybe it is more for Linux:
http://en.wikipedia.org/wiki/RPM_Package_Manager
Regarding other possible solutions, I have found several earlier posts here with similar questions about installing R packages that are not available for the most recent version of R:
Bivariate Poisson Regression in R?
Package ‘GeneR’ is not available
R Venn Diagram package Venerable unavailable - alternative package?
I have installed the latest version of Rtools and the package 'devtools'. Although I know nothing about them.
There is an archived version of 'Rgraphviz' here:
http://cran.r-project.org/src/contrib/Archive/Rgraphviz/
but I cannot locate an archived version of 'pkgDepTools'.
If I can install the packages on a Windows machine using the above *.rpm files could someone please provide instructions?
If I must use Rtools to build them I might ask more questions because the instructions at the link below are challenging for me:
http://cran.r-project.org/doc/manuals/R-admin.html#Building-from-source
To be completely transparent I am hoping someone might build them for me, if that is possible. Although I recognize the experience and knowledge gained from doing it myself would probably pay off in the long run.
Thank you for any advice.
pkgDepTools and Rgraphviz are BioConductor R packages not ones hosted on CRAN. Unless you configure your R to download packages from those repos, R will report that they are not available; it can only install from repos it has been configured to install from.
To install those BioConductor packages a lite installation method is provided:
source("http://bioconductor.org/biocLite.R")
biocLite(c("pkgDepTools", "Rgraphviz"))
Further details are provided on the Install page of the BioConductor website
In general you can't use rpm packages on Windows; rpm's are the equivalent of a binary package for Linux. Any C/C++/Fortran/etc code will have been compiled for Linux not Windows. If a package really isn't available for your version of R then check if there is a reason stated on CRAN (usually Windows binaries take a few days longer to produce or there may be requirements for software not available on the CRAN Windows build machines). You can try the WinBuilder service run by Uwe Ligges to build Windows Binaries of packages for you, but if the package was on CRAN and now isn't that suggests it no longer works with current R and can not be built.
In general try a wider search for packages; the first hit in my Google search results under the search string "pkgDepTools" is the Bioconductor page for the package which includes a link to the Windows binary and instructions on how to install the package from within R.
I think this merits an answer rather than a comment.
A gentleman at Bioconductor helped me get Rgraphviz installed. The primary problem was that the version of Rgraphviz I had downloaded only seems to work with the 32-bit version of R and I was running a 64-bit version of R. I was able to install Rgraphviz in the 32-bit version of R.
I had also made an error or two in the PATH statement during some of my attempts to install Rgraphviz. However, the post above in my second comment provides the instructions for installation.
You just, it seems, cannot install the normal download version of Rgraphviz in the 64-bit version of R.
I think many of our emails back and forth are now posted on the Bioconductor forum.
I might edit this answer with more detailed instructions in the next 24-hours.