Linking Bash R to RStudio, Version/Package Libraries Out of Sync - r

I am struggling with how to link/sync the version of R that I access from the bash terminal on Mac OSX to the version of R (and R libraries) that I have in R Studio.
Some background:
I installed R/R studio by downloading the most recent versions available from the developer's websites as of 10/9/2016.
I previously had R installed on bash, but that version was 3.2.5 not 3.3.1 that I downloaded online. So if I tried to open an R script from bash, it would launch a deprecated version of RStudio that crashed.
To fix this, I used Brew to unlink the old version of R, and reinstall R in bash.
brew unlink r
brew install R
The Problems:
Now when I launch an R script from terminal, it opens the correct version of RStudio, which has a version:
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
However, if in bash I simply launch R using $ R, I have version:
R version 3.3.0 (2016-05-03) -- "Supposedly Educational"
Furthermore, the packages installed in RStudio are not linked. In Rstudio I can load a package library such as library(tidyverse) without error.
In bash's $ R, the above command library(tidyverse) throws an error:
Error in library(tidyverse) : there is no package called ‘tidyverse’
What I would like is a way to link the bash version of R and Rstudio such that the R-versions are the same and such that packages installed in R are recognized in RStudio, and RStudio installed packages can load in bash R.
Thanks for your help.

The default behavior should be that R and Rstudio share the same versions and packages. I imagine the issue you're seeing has to do with having an outdated version of homebrew at the time of install.
I would recommend uninstalling and re-installing, as I was unable to reproduce your issue using the latest Homebrew packages:
brew uninstall r
brew update
brew update # (run twice)
brew cleanup
brew doctor
Fix any issues raised by brew doctor
brew tap homebrew/science
brew install r
I did not have Rstudio installed, so I installed it from Homebrew using cask -- This should not be necessary if you already have Rstudio installed from the developer's site.
brew cask install rstudio
After taking these steps I get the following in both R Studio and in the terminal:
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
library(tidyverse)
Error in library(tidyverse) : there is no package called ‘tidyverse’
At this point, in my terminal window, I ran:
install.packages("tidyverse")
Finally, returning to R Studio after the install:
> library(tidyverse)
Loading tidyverse: ggplot2
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
Conflicts with tidy packages --------------------
filter(): dplyr, stats
lag(): dplyr, stats

Related

cannot install phytools in ubuntu 18.04 with R 3.6

cannot install phytools
tried with devtools
library(devtools)
install_github("liamrevell/phytools")
and
install.packages("phytools")
I keep getting the same error
ERROR: dependency ‘mnormt’ is not available for package ‘phytools’
and I cannot install mnormt because
package ‘mnormt’ is not available (for R version 3.6.3)
gfortran is already installed in my system
GNU Fortran (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
any help is highly appreciated,
thanks
On Ubuntu Linux I cannot get R to update to the latest version (>4.0 at the time of writing), so, like Dirk suggests I have to install an older version of the package, one compatible with the version of R I am running.
My R version is 3.6.3, released feb 2020
I go to the mnormt page and click on "old sources" https://cran.r-project.org/src/contrib/Archive/mnormt/
I see that version 1.5-6 is the most recent release which is prior to my version of R
Following these pages: "Installing older versions of packages" https://support.rstudio.com/hc/en-us/articles/219949047-Installing-older-versions-of-packages I copy the relevant url into this code and run it in R
packageurl <- "https://cran.r-project.org/src/contrib/Archive/mnormt/mnormt_1.5-6.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
Which fixes my problem installing mnormt and also allows packages which depend on it to be installed in the standard way (as far as I tested it)
The current version of mnormt depends on a the current version of R; you chose to remain a version behind.
So just install the previous version of mnormt, for example via
cd /tmp
wget https://cran.r-project.org/src/contrib/Archive/mnormt/mnormt_1.5-7.tar.gz
R CMD INSTALL mnormt_1.5-7.tar.gz
Prefix that last INSTALL command with sudo, or change the permission/group membership of /usr/local/lib/R/site-library, if R tells you it cannot write there.
Once mnormt is installed, proceed with the installation of phytools.
Try to add the tag version to install command, for example: devtools::install_github('cran/mnormt#R-3.0.3')
Check what version you need and replace the tag after the '#'.

R package was installed by version with different internals

On my Win 7 Ent x64 I installed RStudio R-3.4.2.
I installed few packages that I need (RPostgreSQL, sqldf, etc..)
But when I'm executing code, these libraries give me errors:
library(RPostgreSQL)
Error: package ‘RPostgreSQL’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
In addition: Warning message:
package ‘RPostgreSQL’ was built under R version 3.5.0
All of the packages are downloaded from CRAN. RPostgrSQL is 0.6-2 version.
I'm pretty sure that solution is quite simple, but I searched a lot and still cannot find the solution.
How did you install the package RPostgreSQL? If you used
install.packages("RPostgreSQL") on your Windows it installed using binaries, which may have been built using a different R version. In your case, 3.5.0 vs 3.4.2.
Try using install.packages("RPostgreSQL", type="source"). This way your machine will compile the package from source using your version of R, and it should work.
If the package needs C/C++/Fortran compilation, you will als need RTools installed on your machine.
You can try to find all packages installed with the old version R like this:
grep 'Built: R 3.4' /usr/local/lib/R/site-library/*/DESCRIPTION > temp
and then you can uninstall the packages with remove.packages()

How to deal with R packages from CRAN which are more recently built than Anaconda's Jupyter library?

There are answered questions for how to install R packages which do not come in the r-essentials build for Jupyter. But the R version which comes with Anaconda Jupyter is sometimes back a level from the most recent at CRAN.
The trouble is that when packages outside of r-essentials are loaded, a warning is issued that the packages have been built with an R version which is more recent than that installed. Installation continues, but there clearly is the risk that because of the version skew between the packages and the R version, something could go wrong during execution.
Is there an always up-to-date r-essentials some place which can be used with Anaconda Jupyter?
This is for Windows 7, and R version 3.4.3.

Conda install R 3.4.0

I am trying to install R 3.4.0 through conda but seems like is currently missing in the channel.
((Renv)) $ conda install -c r r=3.4.0
gives
Fetching package metadata ...........
Solving package specifications: .
Error: Package missing in current linux-64 channels:
- r 3.4.0*
Is there any way I can install 3.4.0 through in a conda environment?
The latest version of r available through the r channel is 3.3.2. You can install that like this:
conda install -c r r=3.3.2
You can always look through anaconda.org to look at a complete list of packages from default and community channels.
You can now install R 3.4.1 through conda.

Install package "MareyMap" in R or RStudio on Mac. "Installation of package had non-zero exit status"

I am not able to install the R package "MareyMap" in neither in R nor RStudio on my Macbook Pro 10.10.5 OS X Yosemite
This package requires the pre installation of packages "trkplot" and "tcltk", which I installed succesfully. I also tried installing it after installing R through homebrew, without success.
Every time I tried to install "MareyMap" after the R prompt, I get this:
Warning message:
In install.packages("MareyMap") :
installation of package ‘MareyMap’ had non-zero exit status
Please help !
I am not very homebrew or Macs but you may wanna make sure you have the latest version of R. The MareyMap package was just developed in August of 2015 so if you have you have an old version of R perhaps upgrading to 3.2.2 or 3.2.3 might help? I was able to install it with 3.2.2 but not on my other computer which had 3.1.1

Resources