Ubuntu16.04 安装R与RStudio
安裝R語言
我們使用apt的方式進行安裝,步驟如下:
首先需要在/etc/apt/sources.list文件的末尾添加
deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu artful/ deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu xenial/ deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu trusty/在/etc/apt/sources.list文件中,用您喜歡的CRAN鏡像的實際URL替換<my.favorite.cran.mirror>。有關CRAN鏡像列表,請參閱https://cran.r-project.org/mirrors.html。本處使用的是清華的https源deb https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/linux/ubuntu xenial/。然后執行下面的步驟:
sudo apt-get update sudo apt-get install r-base # 需要從源代碼編譯R軟件包的用戶[例如軟件包維護人員或任何使用install.packages() # 安裝軟件包的人)也應該安裝r-base-dev軟件包: sudo apt-get install r-base-dev之后為可選內容
Ubuntu的R軟件包與Debian軟件相似。您可以在位于https://cran.R-project.org/bin/linux/debian/的Debian README文件中找到更多信息。
R或其某些軟件包的安裝和編譯可能需要來自“backports”存儲庫的Ubuntu軟件包。因此,建議使用類似條目激活backports存儲庫
deb https://<my.favorite.ubuntu.mirror>/ trusty-backports main restricted universe在你的/etc/apt/sources.list文件中。有關Ubuntu鏡像列表,請參閱https://launchpad.net/ubuntu/+archivemirrors。
安裝成功之后,清華源默認3.4.4,還算比較新,如果有安裝依賴問題請參考[我的另外一篇文章],此處不在過多描述。(https://blog.csdn.net/fontthrone/article/details/80412340)
其他安裝方式建議參考官方說明(此處鏈接為清華的HTTPS地址
安裝RStudio
安裝
想要安裝RStudio需要先安裝R語言
RStudio的安裝也十分的便捷,直接點進去官網地址下載安裝即可即可,RStudio-Server也可以使用以下命令如下:
# 安裝rstudio-server sudo apt-get install gdebi-core wget https://download2.rstudio.org/rstudio-server-1.1.453-amd64.deb sudo gdebi rstudio-server-1.1.453-amd64.debRStudio的下載地址在這里
本人使用的是rstudio-server,安裝完成之后會默認啟動,默認登錄賬戶密碼為系統登錄的賬戶與密碼。此時請訪問http://localhost:8787/ 登陸之后效果如下:
常用命令
查看端口:ps -aux|grep rstudio
新建賬戶:
useradd -d /home/R -m R,創建用戶的同時指定主目錄
passwd R,設置密碼
系統設置:
主要有兩個配置文件,默認文件不存在
/etc/rstudio/rserver.conf
/etc/rstudio/rsession.conf
系統管理:
rstudio-server start #啟動 rstudio-server stop #停止 rstudio-server restart #重啟查看運行中R進程 rstudio-server active-sessions 指定PID,停止運行中的R進程 rstudio-server suspend-session <pid> 停止所有運行中的R進程 rstudio-server suspend-all 強制停止運行中的R進程,優先級最高,立刻執行 rstudio-server force-suspend-session <pid> rstudio-server force-suspend-all RStudio Server臨時下線,不允許web訪問,并給用戶友好提示 rstudio-server offline RStudio Server臨時上線 rstudio-server online參考
總結
以上是生活随笔為你收集整理的Ubuntu16.04 安装R与RStudio的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu下安装依赖的几个解决方案
- 下一篇: 深入浅出统计学 第一章 数据的可视化