Jupyter 安装 R 环境 | 在jupyter notebook中使用R

方法1(最简单)

  • 将镜像设为清华镜像,这样下的快,而且避免墙
options(repos=structure(c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")))
  • 安装
install.packages('IRkernel')
  • 激活
IRkernel::installspec()

方法2(从github)

devtools::install_github('IRkernel/IRkernel')
IRkernel::installspec()

但是使用github下载时,可能会出现编码问题:

句法分析器24行里不能有多字节字符

编码问题的话,在设置中设置code的默认编码为中文,并运行以下命令:

Sys.setlocale("LC_ALL","Chinese")

或者墙的问题:

 required package could not be found 

无解。

方法3(本地)

先从github克隆过来(当然直接下载、解压也行):

git clone https://github.com/IRkernel/IRkernel.git

进入该文件夹,注意要有setup。 在该文件夹中打开CMD,先build(),再install(),最后再去激活

IRkernel::installspec()

最后就可以在Jupyter中使用啦

原文地址:https://www.cnblogs.com/heenhui2016/p/12528066.html