mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-09 01:30:10 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
55a920ad3c
@ -1,59 +0,0 @@
|
|||||||
[#]: collector: (lujun9972)
|
|
||||||
[#]: translator: (geekpi)
|
|
||||||
[#]: reviewer: ( )
|
|
||||||
[#]: publisher: ( )
|
|
||||||
[#]: url: ( )
|
|
||||||
[#]: subject: (USB4 gets final approval, offers Ethernet-like speed)
|
|
||||||
[#]: via: (https://www.networkworld.com/article/3435113/usb4-gets-final-approval-offers-ethernet-like-speed.html)
|
|
||||||
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
|
|
||||||
|
|
||||||
USB4 gets final approval, offers Ethernet-like speed
|
|
||||||
======
|
|
||||||
USB4 could be a unifying interface that eliminates bulky cables and oversized plugs and provides throughput that satisfies everyone laptop users to server administrators.
|
|
||||||
Intel
|
|
||||||
|
|
||||||
The USB Implementers Forum (USB-IF), the industry consortium behind the development of the Universal Serial Bus (USB) specification, announced this week it has finalized the technical specifications for USB4, the next generation of the spec.
|
|
||||||
|
|
||||||
One of the most important aspects of USB4 (they have dispensed with the space between the acronym and the version number with this release) is that it merges USB with Thunderbolt 3, an Intel-designed interface that hasn’t really caught on outside of laptops despite its potential. For that reason, Intel gave the Thunderbolt spec to the USB consortium.
|
|
||||||
|
|
||||||
Unfortunately, Thunderbolt 3 is listed as an option for USB4 devices, so some will have it and some won’t. This will undoubtedly cause headaches, and hopefully all device makers will include Thunderbolt 3.
|
|
||||||
|
|
||||||
**[ Also read: [Your hardware order is ready. Do you want cables with that?][1] ]**
|
|
||||||
|
|
||||||
USB4 will use the same form factor as USB type-C, the small plug used in all modern Android phones and by Thunderbolt 3. It will be backwards compatible with USB 3.2, USB 2.0, as well as Thunderbolt. So, just about any existing USB type-C device can connect to a machine featuring a USB4 bus but will run at the connecting cable’s rated speed.
|
|
||||||
|
|
||||||
### USB4: Less bulk, more speed
|
|
||||||
|
|
||||||
Because it supports Thunderbolt 3, the new connection will support both data and display protocols, so this could mean the small USB-C port replacing the big, bulky DVI port on monitors, and monitors coming with multiple USB4 ports to act as a hub.
|
|
||||||
|
|
||||||
Which gets to the main point of the new standard: It offers dual-lane 40Gbps transfer speed, double the rate of USB 3.2, which is the current spec, and eight times that of USB 3. That’s Ethernet speed and should be more than enough to keep your high-definition monitor fed with plenty of bandwidth for other data movement.
|
|
||||||
|
|
||||||
USB4 also has better resource allocation for video, so if you use a USB4 port to move video and data at the same time, the port will allocate bandwidth accordingly. This will allow a computer to use both an external GPU in a self-contained case, which have come to market only because of Thunderbolt 3, and an external SSD.
|
|
||||||
|
|
||||||
**[ [Get certified as an Apple Technical Coordinator with this seven-part online course from PluralSight.][2] ]**
|
|
||||||
|
|
||||||
This could open up all kinds of new server designs because large, bulky devices, such as GPUs or other cards that won’t go easily into a 1U or 2U case, can now be externally attached and run at speeds comparable to an internal device.
|
|
||||||
|
|
||||||
Of course, it will be a while before we see PCs with USB4 ports, never mind servers. It took years to get USB 3 into PCs, and uptake for USB-C has been very slow. USB 2 thumb drives are still the bulk of the market for those devices, and motherboards are still shipping with USB 2 on them.
|
|
||||||
|
|
||||||
Still, USB4 has the potential to be a unifying interface that gets rid of bulky cables that have oversized plugs and provides throughput that can satisfy everyone from a laptop user to a server administrator.
|
|
||||||
|
|
||||||
Join the Network World communities on [Facebook][3] and [LinkedIn][4] to comment on topics that are top of mind.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://www.networkworld.com/article/3435113/usb4-gets-final-approval-offers-ethernet-like-speed.html
|
|
||||||
|
|
||||||
作者:[Andy Patrizio][a]
|
|
||||||
选题:[lujun9972][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://www.networkworld.com/author/Andy-Patrizio/
|
|
||||||
[b]: https://github.com/lujun9972
|
|
||||||
[1]: https://www.networkworld.com/article/3278052/your-hardware-order-is-ready-do-you-want-cables-with-that.html
|
|
||||||
[2]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fapple-certified-technical-trainer-10-11
|
|
||||||
[3]: https://www.facebook.com/NetworkWorld/
|
|
||||||
[4]: https://www.linkedin.com/company/network-world
|
|
@ -1,5 +1,5 @@
|
|||||||
[#]: collector: (lujun9972)
|
[#]: collector: (lujun9972)
|
||||||
[#]: translator: ( )
|
[#]: translator: (wxy)
|
||||||
[#]: reviewer: ( )
|
[#]: reviewer: ( )
|
||||||
[#]: publisher: ( )
|
[#]: publisher: ( )
|
||||||
[#]: url: ( )
|
[#]: url: ( )
|
||||||
|
@ -1,209 +0,0 @@
|
|||||||
[#]: collector: (lujun9972)
|
|
||||||
[#]: translator: ( )
|
|
||||||
[#]: reviewer: ( )
|
|
||||||
[#]: publisher: ( )
|
|
||||||
[#]: url: ( )
|
|
||||||
[#]: subject: (How to Install and Use R on Ubuntu)
|
|
||||||
[#]: via: (https://itsfoss.com/install-r-ubuntu/)
|
|
||||||
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
|
|
||||||
|
|
||||||
How to Install and Use R on Ubuntu
|
|
||||||
======
|
|
||||||
|
|
||||||
_**Brief: This tutorial teaches you to install R on Ubuntu. You’ll also learn how to run your first R program in Ubuntu using various methods.**_
|
|
||||||
|
|
||||||
[R][1], together with Python, is the most commonly used programming language for statistical computing and graphics, making it easy to work with data. With the growing interest in data analysis, data visualization, data science (the machine learning craze), it is now more popular than ever and is a great tool for anyone looking to dive into this fields.
|
|
||||||
|
|
||||||
The good thing about R is that its syntax is pretty straight-forward and you can find many tutorials/guides on how R is used in the real world.
|
|
||||||
|
|
||||||
In this article, I’ll cover how to install R on Ubuntu Linux. I’ll also show you how to run your first R program in Linux.
|
|
||||||
|
|
||||||
![][2]
|
|
||||||
|
|
||||||
### Installing R on Ubuntu
|
|
||||||
|
|
||||||
**R** is included in the Ubuntu repositories. It can be easily installed using:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt install r-base
|
|
||||||
```
|
|
||||||
|
|
||||||
Do note that this may install a slightly older version. At the time of writing this article, Ubuntu offers version 3.4 whereas the latest is version 3.6.
|
|
||||||
|
|
||||||
_I advise sticking with whichever version Ubuntu provides unless you must use the newer version._
|
|
||||||
|
|
||||||
In order to get the latest version (or any specific version for that matter), you must use **[CRAN][3]** (The Comprehensive R Archive Network). This is a list of mirrors for downloading the latest version of R. Click on the next section to learn how to install the latest version of R on Ubuntu.
|
|
||||||
|
|
||||||
**How to install latest R version 3.6 on Ubuntu (click to expand)**
|
|
||||||
|
|
||||||
To get the R version 3.6, you need to add the mirror to your sources list. I have simplified it for you in this command:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran35/"
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you should add the key for the repository:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
|
|
||||||
```
|
|
||||||
|
|
||||||
And then update the repository information and install R:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install r-base
|
|
||||||
```
|
|
||||||
|
|
||||||
That’s it.
|
|
||||||
|
|
||||||
[][4]
|
|
||||||
|
|
||||||
Suggested read How to Create a Bootable Windows 10 USB in Linux
|
|
||||||
|
|
||||||
### Using R programming on Ubuntu
|
|
||||||
|
|
||||||
R has more than one use. I’ll go over several methods you can use to run R programs.
|
|
||||||
|
|
||||||
#### Interactive Mode in R
|
|
||||||
|
|
||||||
After having installed **R**, you can run the console using:
|
|
||||||
|
|
||||||
```
|
|
||||||
R
|
|
||||||
```
|
|
||||||
|
|
||||||
This should open up the interactive mode:
|
|
||||||
|
|
||||||
![R Interactive Mode][5]
|
|
||||||
|
|
||||||
This R console is very similar to the **Python** and **Haskell** interactive prompts. You can enter any **R** command and you can do basic mathematical computations. For example:
|
|
||||||
|
|
||||||
```
|
|
||||||
> 20+40
|
|
||||||
[1] 60
|
|
||||||
|
|
||||||
> print ("Hello World!")
|
|
||||||
[1] "Hello World!"
|
|
||||||
```
|
|
||||||
|
|
||||||
You could test plotting too:
|
|
||||||
|
|
||||||
![R Plotting][6]
|
|
||||||
|
|
||||||
You can **quit** using **q()** or pressing **CTRL+c**. When doing so, you will be asked if you want to save a workspace ****image; a workspace ****is an environment for created variables.
|
|
||||||
|
|
||||||
#### Running R program with Rscript
|
|
||||||
|
|
||||||
The second way to run R programs is in directly on the Linux command line. You can do so using **RScript**, a utility included with **r-base**.
|
|
||||||
|
|
||||||
First, you have to save your R program to a file using your [favorite code editor on Linux][7]. The file extension should be .r.
|
|
||||||
|
|
||||||
This is my sample R program printing “Hello World”. I have saved it in a file name hello.r.
|
|
||||||
|
|
||||||
```
|
|
||||||
print("Hello World!")
|
|
||||||
a <- rnorm(100)
|
|
||||||
plot(a)
|
|
||||||
```
|
|
||||||
|
|
||||||
To run the R program, use the command like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
Rscript hello.r
|
|
||||||
```
|
|
||||||
|
|
||||||
You should get back the output:
|
|
||||||
|
|
||||||
```
|
|
||||||
[1] "Hello World!"
|
|
||||||
```
|
|
||||||
|
|
||||||
The plot is going to be saved in the working directory, to a file named **Rplots.pdf**:
|
|
||||||
|
|
||||||
![Rplots.pdf][8]
|
|
||||||
|
|
||||||
**Note:** _**Rscript**_ _doesn’t load the_ _**methods**_ _package by default. Make sure to [load it explicitly][9] in your script_.
|
|
||||||
|
|
||||||
#### Run R scripts with RStudio in Ubuntu
|
|
||||||
|
|
||||||
The most common way to use **R** is using [RStudio][10], a great cross-platform open source IDE. You can [install it using deb file in Ubuntu][11]. Download the deb file from the link below. You’ll have to scroll down a bit to locate the DEB files for Ubuntu.
|
|
||||||
|
|
||||||
[Download RStudio for Ubuntu][12]
|
|
||||||
|
|
||||||
Once you download the DEB file, just double click on it to install it.
|
|
||||||
|
|
||||||
Once installed, search for it in the menu and start it. The home window of the application should pop up:
|
|
||||||
|
|
||||||
![RStudio Home][13]
|
|
||||||
|
|
||||||
Here you have a working console, just like the one you got in the terminal with the **R** command.
|
|
||||||
|
|
||||||
[][14]
|
|
||||||
|
|
||||||
Suggested read Setting Up Python Environments In Linux and Unix Systems
|
|
||||||
|
|
||||||
To create a file, in the top bar click on **File** and select **New File > Rscript** (or **CTRL+Shift+n)**:
|
|
||||||
|
|
||||||
![RStudio New File][15]
|
|
||||||
|
|
||||||
Press **CTRL+s** to save the file and choose a location and a name it:
|
|
||||||
|
|
||||||
![RStudio Save File][16]
|
|
||||||
|
|
||||||
After doing so, click on **Session > Set Working Directory > To Source File Location** to change the working directory to the location of your script:
|
|
||||||
|
|
||||||
![RStudio Working Directory][17]
|
|
||||||
|
|
||||||
You are now ready to go! Write in your code and click run. You should be able to see output both in the console and in the plotting window:
|
|
||||||
|
|
||||||
![RStudio Run][18]
|
|
||||||
|
|
||||||
**Wrapping Up**
|
|
||||||
|
|
||||||
In this article, I showed you step by step how to get started using the **R** programming language on an Ubuntu system. I covered several ways you can go about this: **R console** – useful for testing, **Rscript** – for the terminal lover, **RStudio** – the IDE for your needs.
|
|
||||||
|
|
||||||
Whether you are willing to get into data science or simply love statistics, **R** is a good addition to your programming arsenal, being the perfect tool for analyzing data.
|
|
||||||
|
|
||||||
If you are absolutely new to R, let me recommend you this excellent book that will teach you fundamentals of R. It’s available on Amazon Kindle.
|
|
||||||
|
|
||||||
Preview | Product | Price |
|
|
||||||
---|---|---|---
|
|
||||||
![Learn R in a Day][19] ![Learn R in a Day][19] | [Learn R in a Day][20] | | [Buy on Amazon][21]
|
|
||||||
|
|
||||||
Do you use **R**? Are you just getting into it? Let us know more about how and why you use or want to learn to use **R**!
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://itsfoss.com/install-r-ubuntu/
|
|
||||||
|
|
||||||
作者:[Sergiu][a]
|
|
||||||
选题:[lujun9972][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://itsfoss.com/author/sergiu/
|
|
||||||
[b]: https://github.com/lujun9972
|
|
||||||
[1]: https://www.r-project.org/
|
|
||||||
[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/install-r-on-ubuntu.jpg?resize=800%2C450&ssl=1
|
|
||||||
[3]: https://cran.r-project.org/
|
|
||||||
[4]: https://itsfoss.com/bootable-windows-usb-linux/
|
|
||||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/r_interactive_mode.png?fit=800%2C516&ssl=1
|
|
||||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/r_plotting.jpg?fit=800%2C434&ssl=1
|
|
||||||
[7]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/
|
|
||||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rplots_pdf.png?fit=800%2C539&ssl=1
|
|
||||||
[9]: https://www.dummies.com/programming/r/how-to-install-load-and-unload-packages-in-r/
|
|
||||||
[10]: https://www.rstudio.com/
|
|
||||||
[11]: https://itsfoss.com/install-deb-files-ubuntu/
|
|
||||||
[12]: https://www.rstudio.com/products/rstudio/download/#download
|
|
||||||
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_home.jpg?fit=800%2C603&ssl=1
|
|
||||||
[14]: https://itsfoss.com/python-setup-linux/
|
|
||||||
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_new_file.png?fit=800%2C392&ssl=1
|
|
||||||
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_save_file.png?fit=800%2C258&ssl=1
|
|
||||||
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_working_directory.png?fit=800%2C394&ssl=1
|
|
||||||
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_run.jpg?fit=800%2C626&ssl=1
|
|
||||||
[19]: https://i1.wp.com/images-na.ssl-images-amazon.com/images/I/51oIJTbUlnL._SL160_.jpg?ssl=1
|
|
||||||
[20]: https://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00GC2LKOK (Learn R in a Day)
|
|
||||||
[21]: https://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00GC2LKOK (Buy on Amazon)
|
|
@ -1,5 +1,5 @@
|
|||||||
[#]: collector: (lujun9972)
|
[#]: collector: (lujun9972)
|
||||||
[#]: translator: ( )
|
[#]: translator: (geekpi)
|
||||||
[#]: reviewer: ( )
|
[#]: reviewer: ( )
|
||||||
[#]: publisher: ( )
|
[#]: publisher: ( )
|
||||||
[#]: url: ( )
|
[#]: url: ( )
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
[#]: collector: (lujun9972)
|
||||||
|
[#]: translator: (geekpi)
|
||||||
|
[#]: reviewer: ( )
|
||||||
|
[#]: publisher: ( )
|
||||||
|
[#]: url: ( )
|
||||||
|
[#]: subject: (USB4 gets final approval, offers Ethernet-like speed)
|
||||||
|
[#]: via: (https://www.networkworld.com/article/3435113/usb4-gets-final-approval-offers-ethernet-like-speed.html)
|
||||||
|
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
|
||||||
|
|
||||||
|
USB4 获得最终批准,提供类似以太网的速度
|
||||||
|
======
|
||||||
|
USB4 会是一个统一的接口,可以淘汰笨重的电缆和超大的插头,并提供满足从笔记本电脑用户到服务器管理员的每个人的吞吐量。
|
||||||
|
|
||||||
|
USB 开发者论坛 (USB-IF) 是通用串行总线 (USB) 规范开发背后的行业协会,本周宣布了它已经完成了下一代 USB4 的技术规范。
|
||||||
|
|
||||||
|
USB4 最重要的一个方面(它们在此版本中省略了首字母缩略词和版本号之间的空格)是它将 USB 与 Intel 设计的接口 Thunderbolt 3 融合在了一起,它尽管有潜力,但在除了笔记本之外并未真正流行起来。出于这个原因,Intel 向 USB 联盟提供了 Thunderbolt 规范。
|
||||||
|
|
||||||
|
不幸的是,Thunderbolt 3 被列为 USB4 设备的一个选项,因此有些设备会有,有些则不会。这无疑会引起头疼,希望所有设备制造商都会包括 Thunderbolt 3。
|
||||||
|
|
||||||
|
USB4 will use the same form factor as USB type-C, the small plug used in all modern Android phones and by Thunderbolt 3. It will be backwards compatible with USB 3.2, USB 2.0, as well as Thunderbolt. So, just about any existing USB type-C device can connect to a machine featuring a USB4 bus but will run at the connecting cable’s rated speed.
|
||||||
|
|
||||||
|
### USB4:体积更小,速度更快
|
||||||
|
|
||||||
|
因为它支持 Thunderbolt 3,所以新连接将同时支持数据和显示协议,因此这可能意味着小型 USB-C 端口取代了显示器上庞大的 DVI 端口,而显示器则带有多个 USB4 端口来作为集线器。
|
||||||
|
|
||||||
|
新标准的主要内容:它提供双通道 40Gbps 传输速度,是当前 USB 3.2 规格的两倍,是 USB 3 的八倍。这个以太网的速度,应该足够给你的高清显示器以及其他数据传输提供足够的带宽。
|
||||||
|
|
||||||
|
USB4 对视频还有更好的资源分配,因此如果你使用 USB4 端口同时传输视频和数据,端口将相应地分配带宽。这将允许计算机同时使用外部独立 GPU(因为有 Thunderbolt 3,它已经上市 ) 和外部 SSD。
|
||||||
|
|
||||||
|
这可能会启发各种新的服务器设计,因为大型、笨重的设备,如 GPU 或其他不易进入 1U 或 2U 机箱的卡,现在可以外部连接并以与内部设备相当的速度运行。
|
||||||
|
|
||||||
|
当然,我们看到配备 USB4 端口的电脑还需要一段时间,更别说服务器了。将 USB 3 用于 PC 花费了数年时间,而 USB-C 的采用速度非常缓慢。 USB 2 的 U 盘仍然是这些设备的主要市场,并且主板仍然带有 USB 2。
|
||||||
|
|
||||||
|
尽管如此,USB4 还是有可能成为一个统一的接口,可以摆脱拥有超大插头的笨重电缆,并提供满足从笔记本电脑用户到服务器管理员的每个人的吞吐量。
|
||||||
|
|
||||||
|
在 [Facebook][3] 和 [LinkedIn][4] 上加入 Network World 社区,评论最新主题。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://www.networkworld.com/article/3435113/usb4-gets-final-approval-offers-ethernet-like-speed.html
|
||||||
|
|
||||||
|
作者:[Andy Patrizio][a]
|
||||||
|
选题:[lujun9972][b]
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://www.networkworld.com/author/Andy-Patrizio/
|
||||||
|
[b]: https://github.com/lujun9972
|
||||||
|
[3]: https://www.facebook.com/NetworkWorld/
|
||||||
|
[4]: https://www.linkedin.com/company/network-world
|
211
translated/tech/20190628 How to Install and Use R on Ubuntu.md
Normal file
211
translated/tech/20190628 How to Install and Use R on Ubuntu.md
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
[#]: collector: (lujun9972)
|
||||||
|
[#]: translator: (guevaraya)
|
||||||
|
[#]: reviewer: ( )
|
||||||
|
[#]: publisher: ( )
|
||||||
|
[#]: url: ( )
|
||||||
|
[#]: subject: (How to Install and Use R on Ubuntu)
|
||||||
|
[#]: via: (https://itsfoss.com/install-r-ubuntu/)
|
||||||
|
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
|
||||||
|
|
||||||
|
如何在Ubuntu上安装和使用R语言
|
||||||
|
======
|
||||||
|
|
||||||
|
_**简介: 这个教程是指导如何在Ubuntu上安装R语言。同时可以学习到如何在Ubuntu上用不同方法运行简单的R语言程序**_
|
||||||
|
|
||||||
|
[R][1] ,和Python一样,他是在统计计算和图形处理上最常用的编程语言,易于处理数据。随着数据分析,数据可视化,数据科学(机器学习热)的火热化,对于想深入这一领域的人来说,它是一个很好的工具。
|
||||||
|
|
||||||
|
R语言的优点是他的语法非常简练,你可以结合现实生活找到它的很多教程或指南。
|
||||||
|
|
||||||
|
本文将介绍包含如何在Ubuntu下安装R语言,也会介绍在Linux下如何运行第一个R程序。
|
||||||
|
|
||||||
|
![][2]
|
||||||
|
|
||||||
|
### 如何在Ubuntu上安装R语言
|
||||||
|
|
||||||
|
**R** 默认在Ubuntu的软件库里。用以下命令很容易安装:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt install r-base
|
||||||
|
```
|
||||||
|
|
||||||
|
请注意可能会安装一个老版本。在我写这篇文字的时候,Ubuntu已经提供的3.4的,但是最新的是3.6.
|
||||||
|
|
||||||
|
_我建议如果不是万不得已就直接使用Ubuntu的配套版本。_
|
||||||
|
如果想安装最新的版本(或特殊情况指定版本),你必须用**[CRAN][3]** (Comprehensive R Archive Network)。这个是R最新版本的镜像,点击进入页面学习如何在Ubuntu上安装R语言。
|
||||||
|
|
||||||
|
**如何在Ubuntu上安装最新3.6版本的R环境 (单击展开)**
|
||||||
|
|
||||||
|
如需获取3.6的版本,需要添加镜像到你的源索引里。我已经简化其命令如下:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran35/"
|
||||||
|
```
|
||||||
|
|
||||||
|
下面你需要添加密钥到服务器中:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
|
||||||
|
```
|
||||||
|
|
||||||
|
然后更新服务器信息并安装R环境:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install r-base
|
||||||
|
```
|
||||||
|
|
||||||
|
就这样安装完成。
|
||||||
|
|
||||||
|
[][4]
|
||||||
|
|
||||||
|
建议阅读在Linux下如何制作可启动 Windows 10的U盘的文章
|
||||||
|
|
||||||
|
### 如何在Ubuntu下使用R语言编程
|
||||||
|
|
||||||
|
R的用法多样,我将介绍运行多个运行R语言的方式。
|
||||||
|
|
||||||
|
#### R语言的交互模式
|
||||||
|
|
||||||
|
安装了R语言后,你可以在控制台上直接运行:
|
||||||
|
|
||||||
|
```
|
||||||
|
R
|
||||||
|
```
|
||||||
|
|
||||||
|
这样会打开交互模式:
|
||||||
|
|
||||||
|
![R Interactive Mode][5]
|
||||||
|
|
||||||
|
R语言的控制与 **Python** 和 **Haskell** 的交互模式很类似. 你可以输入 **R** 命令做一些基本的数学运算,例如:
|
||||||
|
|
||||||
|
```
|
||||||
|
> 20+40
|
||||||
|
[1] 60
|
||||||
|
|
||||||
|
> print ("Hello World!")
|
||||||
|
[1] "Hello World!"
|
||||||
|
```
|
||||||
|
|
||||||
|
你可以测试绘图:
|
||||||
|
|
||||||
|
![R Plotting][6]
|
||||||
|
|
||||||
|
如果想 **退出** 可以用 **q()** 或 按下 **CTRL+c** 键. 接着你会被提示是否保存工程 ****镜像; 一个工程 **** 创建变量的环境。
|
||||||
|
|
||||||
|
#### 用R脚本运行程序
|
||||||
|
|
||||||
|
|
||||||
|
第二种运行R程序的方式是直接在Linux命令行下运行。你可以用**RScript**执行,它是一个包含**r-base**的工具。
|
||||||
|
|
||||||
|
|
||||||
|
首先,你需要用[Linux下常用的编辑器][7]保存R程序到文件。文件的扩展名必须是.r。
|
||||||
|
|
||||||
|
下面是一个打印 "Hello World" 的R程序。你可以保存其为hello.r。
|
||||||
|
|
||||||
|
```
|
||||||
|
print("Hello World!")
|
||||||
|
a <- rnorm(100)
|
||||||
|
plot(a)
|
||||||
|
```
|
||||||
|
|
||||||
|
运行R程序,用下面命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
Rscript hello.r
|
||||||
|
```
|
||||||
|
|
||||||
|
你会得到如下输出结果:
|
||||||
|
|
||||||
|
```
|
||||||
|
[1] "Hello World!"
|
||||||
|
```
|
||||||
|
|
||||||
|
结果将会保存到当前工作目录,文件名为**Rplots.pdf**:
|
||||||
|
|
||||||
|
![Rplots.pdf][8]
|
||||||
|
|
||||||
|
**小提示: **_**Rscript**_ 默认不会加载_**methods**_包。确保在脚本中显式加载它。
|
||||||
|
|
||||||
|
#### 在Ubuntu下用RStudio运行R语言
|
||||||
|
|
||||||
|
最常见的 **R** 环境是[RStudio][10],一个强大的跨平台开源IDE。你可以用deb文件在Ubuntu上安装它。下载deb文件的链接如下。你需要向下滚动找到Ubuntu下的DEB文件。
|
||||||
|
|
||||||
|
[下载 Ubuntu 的 Rstudio][12]
|
||||||
|
|
||||||
|
下载了DEB文件后,直接点击安装。
|
||||||
|
|
||||||
|
下载后从菜单搜索启动它。程序主界面会弹出如下:
|
||||||
|
|
||||||
|
![RStudio 主界面][13]
|
||||||
|
|
||||||
|
现在可以看到和 **R** 命令终端一样的工作台.
|
||||||
|
|
||||||
|
[][14]
|
||||||
|
|
||||||
|
建议阅读 Linux和类Unix系统下的Python 环境的配置
|
||||||
|
|
||||||
|
创建一个文件:点击顶栏 **File** 然后选择 **New File > Rscript**(或 **CTRL+Shift+n)**:
|
||||||
|
|
||||||
|
![RStudio 新建文件][15]
|
||||||
|
|
||||||
|
按下 **CTRL+s** 保存文件选择路径和命名:
|
||||||
|
|
||||||
|
![RStudio 保存文件[16]
|
||||||
|
|
||||||
|
这样做了后,点击 **Session > Set Working Directory > To Source File Location** 修改工作目录为你的脚本路径:
|
||||||
|
|
||||||
|
![RStudio 工作目录][17]
|
||||||
|
|
||||||
|
现在一切准备就绪!敲写代码然后点击运行。你可以在控制台和图形窗口看到结果:
|
||||||
|
|
||||||
|
![RStudio 运行][18]
|
||||||
|
|
||||||
|
**结束语**
|
||||||
|
|
||||||
|
这篇文章,作者展示了如何在Ubuntu下使用**R**语言。包含了一下几个方面:**R 控制台** - 很有用处的常见测试,**Rscript** - 终端达人操作,**RStudio** -你想要的IDE
|
||||||
|
|
||||||
|
无论你正在从事数据科学或仅仅的热爱数据统计,作为一个数据分析工具,**R** 是一个比较好的编程辅助。
|
||||||
|
|
||||||
|
如果你完全是一个新手,我推荐这边书可以教你一些R的基础知识。它在亚马逊Kindle也可以找到。
|
||||||
|
|
||||||
|
预览 | 产品 | 价格 |
|
||||||
|
---|---|---|---
|
||||||
|
![一天学会R语言][19] ![一天学会R语言][19] | [一天学会R语言][20] | | [亚马逊购买][21]
|
||||||
|
|
||||||
|
你想使用 **R**吗?你入门了吗?让我们一起学习如何学习以及为什么要用学习**R**!
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://itsfoss.com/install-r-ubuntu/
|
||||||
|
|
||||||
|
作者:[Sergiu][a]
|
||||||
|
选题:[lujun9972][b]
|
||||||
|
译者:[译者ID](https://github.com/guevara.ya)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://itsfoss.com/author/sergiu/
|
||||||
|
[b]: https://github.com/lujun9972
|
||||||
|
[1]: https://www.r-project.org/
|
||||||
|
[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/install-r-on-ubuntu.jpg?resize=800%2C450&ssl=1
|
||||||
|
[3]: https://cran.r-project.org/
|
||||||
|
[4]: https://itsfoss.com/bootable-windows-usb-linux/
|
||||||
|
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/r_interactive_mode.png?fit=800%2C516&ssl=1
|
||||||
|
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/r_plotting.jpg?fit=800%2C434&ssl=1
|
||||||
|
[7]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/
|
||||||
|
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rplots_pdf.png?fit=800%2C539&ssl=1
|
||||||
|
[9]: https://www.dummies.com/programming/r/how-to-install-load-and-unload-packages-in-r/
|
||||||
|
[10]: https://www.rstudio.com/
|
||||||
|
[11]: https://itsfoss.com/install-deb-files-ubuntu/
|
||||||
|
[12]: https://www.rstudio.com/products/rstudio/download/#download
|
||||||
|
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_home.jpg?fit=800%2C603&ssl=1
|
||||||
|
[14]: https://itsfoss.com/python-setup-linux/
|
||||||
|
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_new_file.png?fit=800%2C392&ssl=1
|
||||||
|
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_save_file.png?fit=800%2C258&ssl=1
|
||||||
|
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_working_directory.png?fit=800%2C394&ssl=1
|
||||||
|
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/06/rstudio_run.jpg?fit=800%2C626&ssl=1
|
||||||
|
[19]: https://i1.wp.com/images-na.ssl-images-amazon.com/images/I/51oIJTbUlnL._SL160_.jpg?ssl=1
|
||||||
|
[20]: https://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00GC2LKOK (Learn R in a Day)
|
||||||
|
[21]: https://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00GC2LKOK (Buy on Amazon)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user