debian安装r
An open-source programming language, R is widely used for developing statistical software, performing data analysis and visualization. R offers many user-generated packages for specific areas of study, which makes it applicable to many fields.
R是一种开放源代码编程语言,被广泛用于开发统计软件,执行数据分析和可视化。 R为特定的研究领域提供了许多用户生成的软件包,这使其可应用于许多领域。
In this tutorial, we will install R and show how to add packages from the official Comprehensive R Archive Network (CRAN).
在本教程中,我们将安装R并演示如何从官方的Integrated R存档网络(CRAN)添加软件包。
To follow along with this tutorial, you will need a Debian 10 server with:
要继续学习本教程,您将需要具有以下功能的Debian 10服务器:
at least 1GB of RAM
至少 1GB的RAM
a non-root user with sudo
privileges
具有sudo
特权的非root用户
To learn how to achieve this setup, follow our Debian 10 initial server setup guide.
要了解如何实现此设置,请遵循Debian 10初始服务器设置指南 。
Once these prerequisites are in place, you’re ready to begin.
一旦满足这些先决条件,就可以开始了。
Because R is a fast-moving project, the latest stable version isn’t always available from Debian’s repositories, so we’ll need to add the external repository maintained by CRAN. In order to do this, we’ll need to install some dependencies for the Debian 10 cloud image.
因为R是一个快速发展的项目,所以Debian的存储库并不总是提供最新的稳定版本,因此我们需要添加CRAN维护的外部存储库。 为此,我们需要为Debian 10云映像安装一些依赖项。
To perform network operations that manage and download certificates, we need to install dirmngr
so that we can add the external repository.
要执行管理和下载证书的网络操作,我们需要安装dirmngr
以便我们可以添加外部存储库。
To add a PPA reference to Debian, we’ll need to use the add-apt-repository
command. For installations where this command may not available, you can add this utility to your system by installing software-properties-common
:
要添加对Debian的PPA引用,我们需要使用add-apt-repository
命令。 对于此命令可能不可用的安装,可以通过安装software-properties-common
将此实用程序添加到系统中:
Finally, to ensure that we have HTTPS support for secure protocols, we’ll install the following tool:
最后,为确保我们对安全协议具有HTTPS支持,我们将安装以下工具:
With these dependencies in place, we’re ready to install R.
有了这些依赖关系之后,我们就可以安装R了。
For the most recent version of R, we’ll be installing from the CRAN repositories.
对于R的最新版本,我们将从CRAN存储库中进行安装。
Note: CRAN maintains the repositories within their network, but not all external repositories are reliable. Be sure to install only from trusted sources.
注意: CRAN在其网络内维护存储库,但并非所有外部存储库都是可靠的。 确保仅从受信任的来源进行安装。
Let’s first add the relevant GPG key.
首先添加相关的GPG密钥。
When we run the command, we’ll receive the following output:
运行命令时,将收到以下输出:
Output
Executing: /tmp/apt-key-gpghome.y6W4E0Gtfp/gpg.1.sh --keyserver keys.gnupg.net --recv-key E19F5F87128899B192B1A2C2AD5F960A256A04AF
gpg: key AD5F960A256A04AF: 4 signatures not checked due to missing keys
gpg: key AD5F960A256A04AF: public key "Johannes Ranke (Wissenschaftlicher Berater) " imported
gpg: Total number processed: 1
gpg: imported: 1
Once we have the trusted key, we can add the repository. Note that if you’re not using Debian 10 (Buster), you can look at the supported R Project Debian branches, named for each release.
一旦有了可信密钥,就可以添加存储库。 请注意,如果您不使用Debian 10(Buster),则可以查看受支持的R Project Debian分支 (为每个发行版命名)。
Now, we’ll need to run update
after this in order to include package manifests from the new repository.
现在,我们需要在此之后运行update
,以便包括来自新存储库的软件包清单。
Once this completes running and you’re returned to your prompt, we’re ready to install R with the following command.
一旦运行完成并返回提示,我们就可以使用以下命令安装R了。
If prompted to confirm installation, press y
to continue.
如果提示您确认安装,请按y
继续。
As of the time of writing, the latest stable version of R from CRAN is 3.5.2, which is displayed when you start R.
在撰写本文时,CRAN的R的最新稳定版本是3.5.2,在您启动R时会显示该版本。
Since we’re planning to install an example package for every user on the system, we’ll start R as root so that the libraries will be available to all users automatically. Alternatively, if you run the R
command without sudo
, a personal library can be set up for your user.
由于我们计划为系统上的每个用户安装一个示例程序包,因此我们将以root身份启动R,以便所有用户可以自动使用这些库。 另外,如果您在不使用sudo
情况下运行R
命令,则可以为您的用户设置一个个人库。
Output
R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
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.
>
This confirms that we’ve successfully installed R and entered its interactive shell.
这确认我们已经成功安装了R并进入了它的交互式外壳。
Part of R’s strength is its available abundance of add-on packages. For demonstration purposes, we’ll install txtplot
, a library that outputs ASCII graphs that include scatterplot, line plot, density plot, acf and bar charts:
R的部分优势在于其丰富的附加软件包。 为了演示起见,我们将安装txtplot
,该库输出ASCII图,包括散点图,折线图,密度图,acf和条形图:
Note: The following output shows where the package will be installed.
注意:以下输出显示了软件包的安装位置。
Output
...
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
. . .
This site-wide path is available because we ran R as root. This is the correct location to make the package available to all users.
该站点范围的路径可用,因为我们以root身份运行R。 这是使软件包对所有用户可用的正确位置。
When the installation is complete, we can load txtplot
:
安装完成后,我们可以加载txtplot
:
If there are no error messages, the library has successfully loaded. Let’s put it in action now with an example which demonstrates a basic plotting function with axis labels. The example data, supplied by R’s datasets
package, contains the speed of cars and the distance required to stop based on data from the 1920s:
如果没有错误消息,则说明库已成功加载。 现在,通过一个示例来将其付诸实践,该示例演示带有轴标签的基本绘图功能。 由R的datasets
软件包提供的示例数据包含汽车的速度和基于1920年代的数据所需的停车距离 :
Output
+----+-----------+------------+-----------+-----------+--+
120 + * +
| |
d 100 + * +
i | * * |
s 80 + * * +
t | * * * * |
a 60 + * * * * * +
n | * * * * * |
c 40 + * * * * * * * +
e | * * * * * * * |
20 + * * * * * +
| * * * |
0 +----+-----------+------------+-----------+-----------+--+
5 10 15 20 25
speed
If you are interested to learn more about txtplot
, use help(txtplot)
from within the R interpreter.
如果您想了解有关txtplot
更多信息,请在R解释器中使用help(txtplot)
。
Any precompiled package can be installed from CRAN with install.packages()
. To learn more about what’s available, you can find a listing of official packages organized by name via the Available CRAN Packages By Name list.
可以使用install.packages()
从CRAN安装任何预编译的软件包。 要了解更多有关可用软件包的信息,您可以通过“ 可用的CRAN按名称列出软件包”列表找到按名称组织的正式软件包列表 。
To exit R, you can type q()
. Unless you want to save the workspace image, you can press n
.
要退出R,可以键入q()
。 除非要保存工作区图像,否则可以按n
。
With R successfully installed on your server, you may be interested in this guide on installing the RStudio Server to bring an IDE to the server-based deployment you just completed. You can also learn how to set up a Shiny server to convert your R code into interactive web pages.
在服务器上成功安装R后,您可能会对本指南的安装RStudio服务器感兴趣,以将IDE带入刚刚完成的基于服务器的部署中。 您还可以学习如何设置Shiny服务器,以将R代码转换为交互式网页。
For more information on how to install R packages by leveraging different tools, you can read about how to install directly from GitHub, BitBucket or other locations. This will allow you to take advantage of the very latest work from the active community.
有关如何利用各种工具安装R软件包的更多信息,您可以阅读有关如何直接从GitHub,BitBucket或其他位置进行安装的信息 。 这将使您能够利用活跃社区中的最新作品。
翻译自: https://www.digitalocean.com/community/tutorials/how-to-install-r-on-debian-10
debian安装r