栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > R语言

jupyter notebook运行R语言代码

R语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jupyter notebook运行R语言代码

目录
  • 0引言
  • 1、度娘方案汇集
  • 2、报错信息汇总
  • 3、最终解决
  • 4、代码调试
  • 5、总结

0引言

我是一直以来是使用R语言来建模处理数据。python也只是入门,大大小小的模型都没做过。用的编译器是R语言基础的编译器、Rstudio和jupyter notebook。以后想使用python所以就想着都使用同一个编译脚本。用啥呢?jupyter notebook,感觉还不错还可以写markdown。说做就做去网上找了教程。下面就分享记录一下我今晚踩的坑,希望对大家有用。欢迎评论区留言,看到就回复。

1、度娘方案汇集

网上的攻略是先进行下面的代码然后就OK了。

install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
devtools::install_github('IRkernel/IRkernel')
# 只在当前用户下安装
IRkernel::installspec()
# 或者是在系统下安装
IRkernel::installspec(user = FALSE)

但是到了我这里确实各种报错。

2、报错信息汇总

下面是运行各条命令时的报错汇总。

> install_github("IRkernel/IRkernel")
WARNING: Rtools is required to build R packages, but is not currently installed.
Please download and install Rtools custom from http://cran.r-project.org/bin/windows/Rtools/.
错误: Failed to install 'unknown package' from GitHub:
  schannel: failed to receive handshake, SSL/TLS connection failed
> install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
Warning: 无法在貯藏處https://mirrors.eliteu.cn/CRAN/src/contrib中读写索引:
  无法打开URL'https://mirrors.eliteu.cn/CRAN/src/contrib/PACKAGES'
Warning: 无法在貯藏處https://mirrors.eliteu.cn/CRAN/bin/windows/contrib/3.6中读写索引:
  无法打开URL'https://mirrors.eliteu.cn/CRAN/bin/windows/contrib/3.6/PACKAGES'
Warning message:
packages ‘repr’, ‘IRdisplay’, ‘evaluate’, ‘crayon’, ‘pbdZMQ’, ‘devtools’, ‘uuid’, ‘digest’ are not available (for R version 3.6.2) 
> devtools::install_github('IRkernel/IRkernel')
WARNING: Rtools is required to build R packages, but is not currently installed.
Please download and install Rtools custom from http://cran.r-project.org/bin/windows/Rtools/.
Downloading GitHub repo IRkernel/IRkernel@master
错误: Failed to install 'IRkernel' from GitHub:
  Git does not seem to be installed on your system.
> install.packages("devtools")
--- 在此連線階段时请选用CRAN的鏡子 ---
Warning: failed to download mirrors file (输入中没有多出的行); using local file 'D:/R-3.6.2/doc/CRAN_mirrors.csv'
Warning: 无法在貯藏處https://mirrors.eliteu.cn/CRAN/src/contrib中读写索引:
  无法打开URL'https://mirrors.eliteu.cn/CRAN/src/contrib/PACKAGES'
Warning: 无法在貯藏處https://mirrors.eliteu.cn/CRAN/bin/windows/contrib/3.6中读写索引:
  无法打开URL'https://mirrors.eliteu.cn/CRAN/bin/windows/contrib/3.6/PACKAGES'
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
  downloaded length 0 != reported length 16791
2: package ‘devtools’ is not available (for R version 3.6.2) 

3、最终解决

最后经过探索知道只需要运行下面四行代码即可。

install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
install.packages("IRkernel")  # 这个包直接安装即可,不用什么路径,其他的保持一致与上述链接
IRkernel::installspec()
IRkernel::installspec(user = FALSE)
4、代码调试

下面贴出成功的画面:
1、创建R语言代码

2、代码调试

5、总结

具体使用体验还是等用段时间再来评价,祝大家安装成功。2020年04月14日 23:41

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/855747.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号