R Package Conflicts in Anaconda3 - r

I have installed Anaconda 3 for Mac M1 and I am trying to create a new environment for R. However, everytime I try to do this, I am faced with the below error:
Conda Prompt Error Message
I am faced with this error irrespective of whether I try to do this in anaconda navigator or conda prompt. I have already tried removing Anaconda completely and reinstalling it again but to no avail. Is there anything I can do here?
Update: As requested, here is an additional screenshot:
Mamba install r-eesentials
Mamba install r-essentials output

[Disclosure: I am a volunteer on the Conda Forge R team.]
Conda users who want to use R should prioritize Conda Forge. The Anaconda company has not actively maintained R packages since v3.6.
If installing Conda for the first time, I recommend Miniforge variants (specifically, Mambaforge), rather than the Anaconda distributions (which prioritize defaults/anaconda channel).
Also note that osx-arm64 support for R through Conda is currently sparse. We are actively working on migrating, but for simplicity of workflow, I still recommend Conda users to install a osx-64 version of Conda and use that platform when installing R. You can always create native osx-arm64 environments when you actually need them (e.g., native TensorFlow with Metal support).

Related

Failed to install any R packages in my conda virtual environment

I got my new computer (Mac Pro M1) lately but I am not quite familiar with the MacOS system...
I enjoy using VSCode so I configured it with R language. I created an virtual environment with commands:
conda create -n R python=3.8
conda activate R
conda install -c conda-forge r-base=4.1.2
conda install -c conda-forge r-languageserver
and configured everything following this website. Everything goes fine when I run R language except for installing R packages. Here is a screenshot of my problem.
I can only install packages on R.app:
Can anyone help me? Thanks so much in advance!!!
I really want to get everything ready for coding in R language with VSCode!!! How to solve it? It seems not a problem of permission?
Updated infomation here:
Below are some screenshots showing what are in my R conda environment:
Also, the paths of R and Radian are added to settings of VSCode:

Set up conda environment for R package not on CRAN, installs to wrong location

My goal is to use this package (https://github.com/tiagodc/TreeLS) but it was deprecated from CRAN (https://cran.r-project.org/web/packages/TreeLS/index.html). It requires an older version of R yet its dependencies such as the raster package require R 3.5 or up. I considered two approaches.
using R studio and changing the global options to an older version of R, but I frequently use many geospatial packages and since this package has older dependencies I didn't want to install older versions of packages I use all the time.
Create a virtual environment in Mini Conda 3 dedicated to use for this package. I choose this option because it would be self contained.
Here is the workflow so far.
conda search -c r r
conda create -n newR351 -c conda-forge r-base=3.5.1 -y
conda install -c r rtools -y
Successfully creates a conda environment called newR351 and installs r tools to that environment folder within mini conda 3.
Location of conda environment with R 3.5.1 install
C:\Users\me\Miniconda3\envs\newR351
When I try to install devtools so I can remote install TreeLS from github I get a warning with zero exit status. The devtools package installs, but it installed to my appdata folder and not my mini conda environment.
conda install -c r devtools -y
The downloaded source packages are in
'C:\Users\me\AppData\Local\Temp\RtmpYByvp8\downloaded_packages'
How can I access devtools on my conda environment newR351? Do I need to build a cran skeleton? When I activate R in this environment and try to load the devtools library I get this.
(newR351) C:\Users\me>R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
...
>library(devtools)
Error in library(devtools) : there is no package called 'devtools'
What are best practices for creating an environment specific for an older R package? Anyone else use TreeLS?
First, the devtools isn't showing up because R packages in Conda repositories are conventionally prefixed with "r-", so installing conda install r-devtools should do the trick. However, I don't think Conda is the best strategy here.
Below R version 3.6, the Conda package coverage for R packages is rather poor. Also, installing non-Conda packages that require compilation into a Conda R environment is a pain and generally doesn't work out-of-the-box in my experience. Plus, not only does the TreeLS require compilation, but it has dependencies that are not Conda packages which require compilation. I would avoid this.
Option 1 is feasible. R allows multiple installations, and with manipulating environment variables (I think RSTUDIO_WHICH_R, R_LIBS are the pertinent ones) one can switch between them.
However, were this my situation, I'd spin up a docker container, probably rocker/rstudio:3.5 and use that for this project. Since the underlying image is Linux, it'll take awhile to compile, but you can version it at that point and then always have that available to spin up. This avoids having to muck around with any system settings and should be mostly straight-forward installing.

Installing rsvg library in R 4.0.2 (conda-forge)

I'm facing difficulties downloading the r package rsvg. I created first an environment with conda for the latest R version 4.0.2 following these instructions. I was able to download many other R packages & bioconductor packages without problem, however, this one produces huge pile of lines while configuring it and ends with errors downloadind its dependencies (systemfonts, stringi, stringr, gdtools, magick, svglite, knitr). My exact command is install.packages("rsvg", dependencies =T). Trying to download each of those packages produced also a tree of required dependencies (with configuration fail at the end of each).
Among the lines I noticed this error /user/include/freetype2/freetype/config/ftheader.h:3:12: fatal error x86_64-linux-gnu/freetype2/config/fthreader.h no such file or directory which make me suspect that my R installation is incopmlete or corrupted. I tested it with other R versions (e.g. R 3.6.0) yet the same error appear. Installing it on windows (Rstudio 3.6.2) also didn't work, and now I'm wondering if this package needs to be installed differently or it is system related problem? Any help would be highly appreciated
You need to create a new environment and then you can install R 4.+ in Anaconda. Follow these steps.
conda create --name r4-base
After activating r4-base run these commands
conda install -c conda-forge r-base
conda install -c conda-forge/label/gcc7 r-base
Finally, you will notice r-basa version 4 will be installed.
Thereafter, you can install any supported packages. But with this only, you won't have the ability to use it in the Jupyter notebook. You need to install install.packages('IRkernel') and Jupyter notebook as well if you want to use it. Otherwise you are good to go with R-Studio.
For Jupyter Installation and RKernel.
conda install jupyter
Then open the R console. Write in R console
install.packages('IRkernel')
IRkernel::installspec()
Congrats! You can use Notebook for Python and R.

Installing R Studio with Anaconda

I tried to install R Studio (version 1.1.456) using the anaconda navigator by simply clicking on the install button. It was taking more than an hour, so I just figured it should be stuck.
I then tried to install it through the anaconda prompt but now it has also been stuck for around 30 minutes here:
What can I do to get around this?
Thank you in advance!
For various reasons up-to-date RStudio versions are not availabe on any conda channel I know. #merv's answer is the easiest solution, if you are happy to work with an older version of rstudio. Here is another suggestion, where you install RStudio outside of conda, but configure it to use a particular R installation, which is maintained in your custom conda environment. Step by step, this is how you procede:
Install the latest RStudio from the official sources
Create your custom conda environment CUSTOMENV, including an installation of r-base
conda create -n CUSTOMENV -c conda-forge r-base'>=4.0.0' ... [further packages]
Activate the conda environment
conda activate CUSTOMENV
Start RStudio from console
rstudio &
Important Note: I strongly endorse #mfakaehler's answer since all RStudio builds on Conda have effectively been abandoned. Install RStudio natively and launch from activated environment.
Create a new env instead. E.g.,
conda create --name rstudio_env -c r rstudio
Best practice for Conda is to create new envs for each project rather than using a monolithic base env. Generally, I find that the less one installs in base the better their experience with Conda will be.

How to install Tensorflow for R

I had Tensorflow installed with Anaconda. Now I want use it in R and I need to reinstall Tensorflow, because the note here
NOTE: You should NOT install TensorFlow with Anaconda as there are
issues with the way Anaconda builds the python shared library that
prevent dynamic linking from R.
I already tried to uninstall from Anaconda and install with pip but its came to the same place in anaconda directory. Tesorflow is working from terminal but in R shows Error: Command failed (1)
Anybody can help me to how I can solve the problem? Should I uninstall anaconda and install Tensorflow using pip?
You have several options on what to do. Probably the cleanest one is to install a system-wide python (if not installed yet) and then create a virtual environment. This basically takes your system python binaries and moves them to its own compartment where everythign is isolated from the rest, incl. anaconda. Once you are inside an activated virtual environment you can install all the necessary Python appendages for TensorFlow. Once that is done, make sure you set up a correct environmental PATH for TensorFlow from where R can reach it:
Sys.setenv(TENSORFLOW_PYTHON="/path/to/virtualenv/python/binary")
devtools::install_github("rstudio/tensorflow")
Example of the path to where you installed the virtual environment project would be, I think, something like ~/minion/medvedi/venv_medvedi/bin/python.
This is no longer an issue, the documentation was updated too.
See here:
https://github.com/rstudio/tensorflow/commit/4e1e11d6ba2fe7efe1a03356f96172dbf8db365e
With the help of Keras, we can install the TensorFlow package in R.
install_keras()
library(keras)
devtools::install_github("rstudio/keras")
install_tensorflow(package_url = "https://pypi.python.org/packages/b8/d6/af3d52dd52150ec4a6ceb7788bfeb2f62ecb6aa2d1172211c4db39b349a2/tensorflow-1.3.0rc0-cp27-cp27mu-manylinux1_x86_64.whl#md5=1cf77a2360ae2e38dd3578618eacc03b")
library(tensorflow)
Keras is a high-level neural network API for deep learning from TensorFlow Google.
my suggestion is to install anaconda and create an environment called "r-reticulate".
you can do it using anaconda navigator or
reticulate::conda_create(envname = "r-reticulate")
then to check that env detected by reticulate, use reticulate::conda_python().it must return directory of python.exe for your env.
after that you can install tensorflow by install_tensorflow(). [not working in my case]
so I install the tesnorflow from CMD.
follow these steps:
open the cmd :]
activate the r-reticulate env using conda activate r-reticulate (you may need your directory to conda directory if you did not add conda to your PATH)
use : conda install -c anaconda tensorflow
now in R, you can use TensorFlow.
for installing Keras, you can use pip install Keras. [i tried install_keras() function after the installation of tensorflow, but it ruined my TensorFlow installation also]
Eventually I found the best and fast method to do it in R:
devtools::install_github("rstudio/keras")
library(keras)
install_keras(method = "conda")
install_keras(tensorflow = "gpu")
tensorflow::install_tensorflow()

Resources