因为今天安装R包,学些拓朴数据分析,结果看了好几个包,都没有windows和Mac版本,只有linux的,所以很无奈,只能在虚拟机上安装R。
转载:腾讯原文链接
首先,打开ubuntu左下角的菜单,选择“”软件更新器“或者”软件和更新“”,把源改为“主服务器”,不要选中国的或者其他高校的源。如果你安装的是英文版本ubuntu,也应该选择第一个,大概是“main server". 安装完以后,你可以改回来。你也可以用命令行该,自己度娘看看怎么输入命令行。
第1步 - 添加GPG密钥
以sudo非root用户身份登录到您的Ubuntu 18.04服务器,添加相关的GPG密钥。
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
第2步 - 添加R存储库(这里你要看清楚,不同的Ubuntu版本对应的R也不同,)
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
(R 3.6 packages for Ubuntu on i386 and amd64 are available for most stable Desktop releases of Ubuntu until their official end of life date. However, only the latest Long Term Support (LTS) release is fully supported. As of November 18, 2018 the supported releases are Xenial Xerus (16.04; LTS), Trusty Tahr (14.04; LTS), Bionic Beaver (18.04;LTS), Cosmic Cuttlefish (18.10), and Disco Dingo (19.04). Note, to install R 3.6 packages, a different sources.list entry is needed. See below for details. Even though R has moved to version 3.6, for compatibility the sources.list entry still uses the cran3.5
designation.)
第3步 - 更新包列表
sudo apt update
第4步 - 安装R
sudo apt install r-base
第5步 - 测试安装
以root身份启动R的交互式shell。
sudo -i R
您应该收到类似于以下内容的输出:
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>