Updating R that is used within IPython/ Jupyter

僤鯓⒐⒋嵵緔 提交于 2021-02-07 19:41:31

问题


I wanted to use R within Jupyter Notebook so I installed via R Essentials (see: https://www.continuum.io/blog/developer/jupyter-and-conda-r). The version that got installed is the following:

R.Version()

Out[2]:
$platform
"x86_64-w64-mingw32"
$arch
"x86_64"
$os
"mingw32"
$system
"x86_64, mingw32"
$status
""
$major
"3"
$minor
"1.3"
$year
"2015"
$month
"03"
$day
"09"
$svn rev
"67962"
$language
"R"
$version.string
"R version 3.1.3 (2015-03-09)"
$nickname
"Smooth Sidewalk"

I have attempted to update R and install some packages (like RWeka for example) to no avail. I have looked for various sources but nothing seems to point me in the right direction. Does anyone know what to do?

My main motivation is trying to use R libaries but will get warnings like the following:

library("RWeka")

Warning message:
: package 'RWeka' was built under R version 3.2.4Warning message:
In unique(paths): bytecode version mismatch; using eval

回答1:


If you want to stay with conda packages, try conda update --all, but I think there are still no R 3.2.x packages for windows.

You can also install R via the binary installer available at r-project.org, install the R kernel manually; e.g. via

install_github("irkernel/repr")
install_github("irkernel/IRdisplay")
install_github("irkernel/IRkernel")

and then make this kernel available in the notebook

IRkernel::installspec(name = 'ir32', displayname = 'R 3.2')



回答2:


In short, what you can do is update R on your machine, run the R console from within the anaconda environment and run step 5 and 6 below. This will update the version of R running in your anaconda environment.

For step by step instructions refer the below:

1.Update the latest R version in the R console. Refer this post.

2.Activate the required Anaconda environment in the terminal or Anaconda prompt using the below. Make sure you replace <my_env> with the name of your Jupyter environment.

conda activate my_env

3.Find out your <R_execution_path> using the R console with:

R.home("bin") 

Note: If you get a shortened pathname such as "C:/PROGRA~1/R/R-40~1.2/bin/x64", find the proper long path name by using your file explorer (or any other method).

4.Now execute the R console in your anaconda environment within the terminal or Anaconda prompt. Use your own <R_execution_path> with the below commands.

In the Linux terminal:

sudo <R_execution_path>/R

for example:

sudo /Library/Frameworks/R.framework/Resources/bin/R

OR

for Windows on Anaconda prompt (run as an Administrator and have my_env activated):

cd <R_execution_path>
R.exe

For example:

cd 'C:\Program Files\R\R-4.0.2\bin\x64\'
R.exe

5.Now run the below in the R console within the Jupyter environment

install.packages("IRkernel")
IRkernel::installspec()
q()

6.Restart your Jupyter notebook

jupyter notebook


来源:https://stackoverflow.com/questions/36341820/updating-r-that-is-used-within-ipython-jupyter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!