Can homebrew R and "standard" R for MacOS from CRAN coexist? - r

I am running R 3.6.1 on a Mac Mini running Sierra and a MacBook Pro running El Capitan. I normally get all the R packages that I need from CRAN or github and use them without issues, but I am trying to install and use an R package (NicheMapR) that requires a fortran compiler and this is giving me issues. Even after installing gfortran, the R package still does not work (the fortran code seems to be compiled but the package installation fails). The package developer suggested that installing R via homebrew might solve the problem. On the contrary, my hunch is that it would lead to a world of pain, to quote Walter from the Big Lebowski. My questions are:
What is the advantage of a homebrew version of R for MacOSX over the "regular" version installed from CRAN?
Can the two versions coexist?
Is the homebrew version going to affect the regular one?
Finally: is homebrew going to help or will it simply open a whole
new can of worms?
Many thanks in advance.

Yes, installing from homebrew is a recipe for pain. It's specifically recommended against by the official CRAN binary maintainer see his remarks from March 2016 on r-sig-mac.
Regarding your questions, this can be summarized as:
What is the advantage of a homebrew version of R for MacOSX over the "regular" version installed from CRAN?
Positives: Select your own BLAS and easily work with geospatial tools.
Downsides: Always needing to compile each R package.
Can the two versions coexist?
Yes. The homebrew version installs into a different directory. But, watch out for library collision (see next question). However, you will have to deal with symbolic linking regarding what version of R is accessible from the console and you will also need to look into using RSwitch to switch between R versions.
Is the homebrew version going to affect the regular one?
Yes, if the library paths overlap. There will be problems regarding package installation and loading. Make sure to setup different library paths. To do so, please look at the .libPaths() documentation.
Finally: is homebrew going to help or will it simply open a whole new can of worms?
Yes and no. Unless you know what you're doing, opt for the CRAN version of R and its assorted goodies.

Related

Can't find MRO (Microsoft R Open) installation on MacOS, after installation

Thought I'd give MRO a spin, to see if it speeds up my usage in general.
I can't find the installed R though. Not as a separate, not as an overwrite.
/usr/local/bin/R contains R version 3.4.0 (2017-04-21) -- "You Stupid Darkness", which is also the one used by RStudio.
/Library/Frameworks/R.framework/Versions/ also only contains 3.4.
The GUI "Microsoft R Open.app" has the description R 3.3.0 GUI 1.68 Mavericks build... but it also returns 3.4.
What am I missing?
You've identified a bug in the installer. Thanks!
Looks like we are not installing the MRO framework files because the package installer is detecting a newer version (CRAN 3.4). We will get this fixed in the next release.
In the meantime, you can work around this by renaming /Library/Frameworks/R.framework/Versions/3.4 to /Library/Frameworks/R.framework/Versions/0.3.4 and reinstalling MRO. Then go ahead and rename it back.
Please note, as a part of the install we update the symlinks to point to our version, so if you would prefer the default R installation to be CRAN 3.4 please do the install in the reverse order or manually update the symlink to Current in the Versions folder.

Does installing an R package with Rcpp require Rtools (Windows)

I am making an R package with Rcpp. It works fine on my machine which has Rtools installed. But recently, I tried to install my package locally on a different machine (Windows) and got a compiling error. The reason was that on that machine there was no g++ compiler (for Windows, g++ is provided with Rtools). After installing Rtools, it worked just fine.
So the question is, if I upload it to CRAN, does it still requires users to install Rtools by hand? Or does the function install.package() detect and install Rtools for them?
Also, if you guys know some packages written with Rcpp, please let me know. I'd like to take a look how it works.
So the question is, if I upload it to CRAN, does it still requires users to install Rtools by hand?
No.
Or does the function install.package() detect and install Rtools for them?
No.
What happens is that CRAN builds pre-compiled binary files that can be installed by Windows and MacOS users without the need for compilers and related tools.
Also, if you guys know some packages written with Rcpp, please let me know. I'd like to take a look how it works.
rr <- devtools::revdep("Rcpp")
length(rr) ## 907
or see the Rcpp page on CRAN.
Users, e.g. people who download it via install.package(), are actually downloading a "compiled" version of the packaged called a binary that is maintained by CRAN. They will only ever need a copy of R.
On the other hand, Developers, e.g. people who are creating it, require development tools that are system specific. For those on the Windows platform, they must have a local install of Rtools on their machine. For developers on macOS, they must have their own copies of gfortran binaries and xcode developer line tools.
Lastly, there are many such Rcpp packages available to look to for inspiration...
See the Rcpp CRAN page
Pick a package and then look up the source at http://github.com/cran/packagename
View an annotated list by Dirk here.

R package listed on CRAN but not in available package

I want to install a package that is listed in https://cran.r-project.org/web/packages/available_packages_by_name.html as available in CRAN, but when I check in R the install packages menu or the available.packages() command, I can't see the package there.
Do I need to do something different to install those packages? Why aren't those packages available?
The packages I'm interested on are WikipediR ( https://cran.r-project.org/web/packages/WikipediR/index.html ), WikidataR and WikipediaR.
If it matters, I'm using R 2.15.0 in Windows XP.
See the documentation for ?available.packages...
By default, the return value includes only packages whose version and
OS requirements are met by the running version of R, and only gives
information on the latest versions of packages.
In other words... your R 2.15 is likely too old for the package you are looking to download.
You can try to download the package source manually add the package to the package library usually found somewhere like "win-library/2.15/" but like Cory mentioned it is likely that the older version of R does not support the package build.
The advice given so far is a bit incomplete although I do agree you need to update your R version if you want to use these packages. Looks like they don't need compilation so you might have been able to either install from a local copy or drop R code in, but critically they depend on httr which requires R 3.0.0 or above. They were released only relatively recently, so there will be no Windows binaries from back in 2012. (Your copy of R is from 30-Mar-2012.) Look in the DESCRIPTION file which is presented in a nice web format at the CRAN/package listing:
https://cran.r-project.org/web/packages/WikidataR/index.html
Imports: httr, jsonlite, WikipediR
Suggests: testthat, knitr, pageviews
# only one version of these two
https://cran.r-project.org/src/contrib/Archive/WikidataR/WikidataR_1.0.0.tar.gz
https://cran.r-project.org/src/contrib/Archive/WikipediaR/WikipediaR_1.0.tar.gz
# pick one of these
https://cran.r-project.org/src/contrib/Archive/WikipediR/

R: can rpm files be used with Windows for possibly outdated R packages?

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.

R: RGraphviz installation

I've been trying to install the library using brute force - trying different combinations of the things people have posted in mailing lists (I'm too lazy to list them out one by one, but I think I tried the most of them. I can list that too if it helps anyone.). The results have varied from a harmless message of a missing dll to RGui not being able to start before I remove the library manually. Nevertheless, I haven't succeeded...
Do you know how to install it properly, so that it works? I'm running 64bit Windows 7 and I'm not keen of compiling packages from source. Thanks!
Install Rgraphviz 2.2.1 from Bioconductor
According to the latest README:
Rgraphviz now comes bundles with Graphviz. This should greatly simplify
installation on all platforms, compared with earlier versions.
Bioconductor 2.11 contains a lot of libraries that you might not want or need, but it does seem to be the easiest path to achieving what you want. These are the instructions on the Rgraphviz homepage:
source("http://bioconductor.org/biocLite.R")
biocLite("Rgraphviz")
These instructions work for R x64 2.15.2 on Windows 7
library("Rgraphviz")
Loading required package: graph
Loading required package: grid
set.seed(123)
V <- letters[1:10]
M <- 1:4
g1 <- randomGraph(V, M, 0.2)
plot(g1)
The README inside the source package for RGraphviz contains very some pretty clear instructions.
I think it's a bit user-unfriendly to those who only want to install the binary package, to hint that they might also want to download and unpack a tar.gz file containing the complete source, in order to find some technical info .... which turns out to be absolutely crucial.
One word of warning. If you follow the installation instructions for Rgrahpviz precisely, things won't work. Installing the package graphviz edits the environment PATH, but incorrectly. I didn't notice and I bet lots of others missed it too.
Rgraphviz wants to look for the binary in ...;C:\Graphviz2.20\bin\;
BUT the graphviz install adds a path only as far as ;C:\Graphviz2.20\;.
You'll have to edit it. Older instructions suggest a manual edit anyway, but newer ones leave it to graphviz.
I have same problems to install Rgraphviz (for using it in Bayesian Network packages). I used to get brute force solutions, but, now I trying an other one described here in this page
maybe you had also tried. If you succeed in installing Rgraphviz, I will be grateful if you learn me how to do.
I am using R-Studio on Ubuntu 12.10 x64 and installed Rgraphviz from the BioC software repository. Hope this helps. Eg: http://www.biotricks.net/2012/03/rstudio-and-bioconductor.html
I don't know if you have managed to solve your problem 100% but my installation problem came with the R version. Rgraphiz is developed by Bioconductor and it seems to be outdated. However, I had to use it since I moved to a new company and they are using it in one of their shiny apps for whatever reason.
With that being said, I have a dirty solve that I came up with after a couple of days of struggling with it.
First I include a line in the code which seems to be needed since without that line the shiny app simply doesn't do anything after opening:
if(!requireNamespace('BiocManager', quietly = TRUE))
install.packages('BiocManager')
It's weird that it won't work otherwise.The above line is found on Bioconductor's site: https://www.bioconductor.org/packages/devel/bioc/html/Rgraphviz.html
The second thing you need to do only once is to run the biocLite command below in the R console to install the Rgraphviz package
source("http://bioconductor.org/biocLite.R")
biocLite("Rgraphviz")
The above command I found on another thread: R: RGraphviz installation
Hopefully this update will help you or anyone else.
Since with the version of R 3.6.1 the script http://bioconductor.org/biocLite.R returns this message " Error: With R version 3.5 or greater, install Bioconductor packages using BiocManager; see https://bioconductor.org/install " I solved the problem with the following steps:
Get the list of directories used by R to install libraries and
choose the one with write permissions using: .libPaths()
Installing the "BiocManager" library using: install.packages("BiocManager")
Installation of the library "bioconductor" by forcing the directory
with write permissions using: BiocManager::install("Rgraphviz", lib = "C:/Users/tizbet/Documents/R/win-library/3.6")
I worked on the following R installation:
platform x86_64-w64-mingw32, arch x86_64, os mingw32, system x86_64, mingw32, version.string R version 3.6.1 (2019-07-05)

Resources