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.
Related
I need to install R package fOpitons for a learning module required by society of actuaries. This package seems to be no longer available on CRAN. It was taken down in April 2022 for misrepresentation of authorship and ownership of copyright. None of the links to former versions of the package works. How can I install this package?
https://cran.r-project.org/web/packages/fOptions/index.html
None of the links in this site works.
https://cran-archive.r-project.org/web/checks/2022/2022-04-29_check_results_fOptions.html
(Note for eager "close as duplicate": the Archive/ link for this package is (currently?) broken which is very unusual for CRAN so I spelled out alternative approaches below. That part is likely not a duplicate. Cheers. -D.)
CRAN packages are open source, and even when removed from the current CRAN index for reasons deemed necessary by the CRAN team will always remain available in the Archive/ section of the package.
So the link you provide has as its second line
Formerly available versions can be obtained from the archive.
where the archive link should provide you access to various versions.
However, it is not working, which looks like an error. So I just alerted CRAN to that.
I happen to have maintained fOptions in Debian for a number of years. So you still get the Debian binary packages -- and sources. Most recent versions are at https://packages.debian.org/sid/r-cran-foptions point for example to the source archive: http://deb.debian.org/debian/pool/main/f/foptions/foptions_3042.86.orig.tar.gz
If you can install from source this should do.
Otherwise, there is also a CRAN mirror at GitHub so
https://github.com/cran/fOptions is another choice.
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.
When I install.package() in R on a Windows machine, the package downloads from CRAN and installs. When I do the same on a Linux box, the package usually has to compile (at least, I assume that's what going with all those g++ lines that scroll past).
Why is the package installation method different on Windows?
Other questions and their answers make it clear that using different methods and repositories for Linux particularly, enables users to get more/different packages (particularly using the cran2deb repository). My question is more theoretical in nature: why is the default choice in Windows to download precompiled (binary?) packages whereas the default in Linux seems to be to compile packages from source?
Or to put it another way (based on Dirk's assertion in the second link above), why doesn't CRAN offer binary packages for Unix-type operating systems?
In general, Windows binaries will work on all versions of Windows.
Ditto for the key / current versions of MacOS: the provided binaries work.
Linux, sadly, is more complicated because the different distros lay things out differently. Something I build on Ubuntu or Debian (or, more specifically, a particular release version thereof) may not even work on other releases of the same distro, let alone other distro. In some cases you can get binaries. At some point I (co-)owned a build service for all of CRAN, but it died/broke. All doable with effort, but ... some effort.
So from source it is. That use to be the standard anyway which "Unix" was a catch-all phrase covering SunOS/Solaris, AIX, *BSD, SGI and on and on. Often even with different processors. So source.
There have been attempts to provide 'universal binaries': flatpack and snap are two more recent examples. And then there is of course Docker.
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.