Installing R 4.0.2 version

Viewed 8207

I used to work in R 3.4.0 version. Hovewer, this version doesn't support such packages as keras and tensorflow.

I was adviced to upgrade my R version to the newest one. I downloaded the most recent R version 4.0.2 from the official site, then ran the following code:

install.packages("keras")
library(keras)
install_keras()

And got the following error:

Error in install_keras() :
You should call install_keras() only in a fresh R session that has not yet initialized Keras and TensorFlow (this is to avoid DLL in use errors during installation)

After this, when I tried to quit R session by q() , I faced the following error:

Error: option error has NULL value
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Error: option error has NULL value

I've never faced such an error before. When I used old R version, I typed q() and then had to choose between y and n. No errors appeared.

I'm asking you to help to to solve this problem.

3 Answers

You need to create a new environment and then you can install R 4.+ in Anaconda. Follow these steps.

conda create --name r4-base

enter image description here

After activating r4-base run these commands

conda activate r4-base
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.

enter image description here

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.

Find the location of R.exe on your computer. In my computer, this executable is at

C:\Program Files\R\R-3.4.3\bin

Open another Anaconda Prompt as Administrator and change directories to wherever R.exe is on your computer with cd file path. On my computer, it’s cd C:\Program Files\R\R-3.4.3\bin, but it might be different for you.

Then run R from within Anaconda Prompt in Admin mode with R.exe

You’ll notice that you’re in an R session. From here, run the following three commands into the terminal.

  1. install.packages("devtools")
  2. devtools::install_github("IRkernel/IRkernel")
  3. IRkernel::installspec()

In order, they (1) install the devtools package which gets you the install_github() function, (2) install the IR Kernel from GitHub, and (3) tell Jupyter where to find the IR Kernel.

Open Jupyter notebook and enjoy your new R kernel!

Get more information here

Related