在Jupyter笔记本电脑中使用Windows的R新版本 [英] Using a new windows version of R in Jupyter notebooks

查看:134
本文介绍了在Jupyter笔记本电脑中使用Windows的R新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Windows安装了R版本3.5.1,并将其内容复制到Anaconda3使用的R文件夹中.但是,conda仍将当前版本标识为3.4.3. Anaconda3文件夹中的某个位置是否存在版本ID"文件?

I've installed R version 3.5.1 for windows and copied its contents to the R folder used by Anaconda3. However conda still identifies the current version as 3.4.3. Is there a "version id" file somewhere in the Anaconda3 folders?

推荐答案

简短解决方案

简而言之,您需要在要与Jupyter一起使用的R版本中安装IRkernel软件包,然后将其提供给Jupyter.请参见此处.

In short you need to install a the IRkernel package in the version of R you want to use with Jupyter and then make it available to Jupyter. See here.

诊断

您可能没有意识到您已经安装了两个R.要确认Jupyter Notebook是否属于这种情况,请键入:

You may not be aware that you have two installations of R. To confirm this is the case in a Jupyter Notebook, type:

R.version

这应该返回诸如以下的值:

This should return values such as:

               _  
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          4.3                         
year           2017                        
month          11                          
day            30                          
svn rev        73796                       
language       R                           
version.string R version 3.4.3 (2017-11-30)
nickname       Kite-Eating Tree       

现在打开RStudio或RGui并输入相同的命令,您应该看到不同的输出(忽略任何警告):

Now open RStudio or RGui and input the same command, you should see different output (ignore any warnings):

               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          5.0                         
year           2018                        
month          04                          
day            23                          
svn rev        74626                       
language       R                           
version.string R version 3.5.0 (2018-04-23)
nickname       Joy in Playing   

请特别注意version.stringnickname变量之间的差异.

Note the differences in the version.string and nickname variables in particular.

现在在Jupyter笔记本中输入:

Now in your Jupyter notebook type:

R.home()

哪个将给出如下输出:

"C:/Anaconda3/lib/R"

RStudio或RGui中的同一命令将返回不同的路径,例如:

The same command in RStudio or RGui will return a different path e.g.:

"C:/R/R-35~1.0"

以上值可能与您的计算机上的值不匹配,但是如果它们彼此不同,则以下步骤将允许您使用Jupyter中最新的R实例.

The above values may not match those on your machine, but if they are different to each other the following steps will allow you to use the latest R instance from Jupyter.

更广泛的解决方案

  1. 从Rstudio(或RGui)复制上述R.home()路径
  2. 从开始菜单中打开Anaconda Prompt
  3. 键入cd /d "C:/R/R-35~1.0",其中路径与您复制的路径相同.点击返回.
  4. 键入cd bin.点击返回
  5. 键入R.exe以从该目录启动命令行R
  6. 我们现在需要安装软件包IRkernel.该软件包可将R的版本称为Jupyter内核.键入install.packages('IRkernel')并点击回车.
  7. 键入IRkernel::installspec(name = 'ir35', displayname = 'R 3.5.0')以创建最新的R内核.请注意,您可以将名称和显示名称更改为您想要的任何名称.
  8. 退出R并关闭您正在运行的Jupyter Notebook的所有实例.
  9. 再次启动Jupyter Notebook,然后单击以创建一个新的笔记本.您应该通过下拉框中的显示名称找到可用的内核.
  1. Copy the above R.home() path from Rstudio (or RGui)
  2. Open Anaconda Prompt form the start menu
  3. Type cd /d "C:/R/R-35~1.0" where the path is the same as the one you have copied. Hit return.
  4. Type cd bin. Hit return
  5. Type R.exe to launch the command line R from that directory
  6. We now need to install the package IRkernel. This package makes the version of R callable as an Jupyter kernel. Type install.packages('IRkernel') and hit return.
  7. Type IRkernel::installspec(name = 'ir35', displayname = 'R 3.5.0') to create the latest R kernel. Note you can change the name and display name to be whatever you wish.
  8. Exit R and close any instances of Jupyter Notebooks you have running.
  9. Launch Jupyter Notebook again and click to create a new notebook. You should find your kernel available by its display name in the drop down box.

这篇关于在Jupyter笔记本电脑中使用Windows的R新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆