【772】How to use the R programming language in Jupyter Notebook
参考:How to use the R programming language in Jupyter Notebook
R is a popular programing language for statistics. This topic explains how to use R in a Jupyter Notebook.
-
Make sure Jupyter Notebook is installed on your Home page.
-
To install the R language and r-essentials packages, go to the Environments page.
-
Click Create.
-
Name the environment “r-tutorial”.
-
Next to Packages, select version 3.7.13 of Python.
-
Check the box next to R and select the version of R you want to use.
Note
This topic selects a version of Python that is compatible with most versions of R. Not all versions of Python and R are compatible. If you attempt to create an environment with incompatible versions, Navigator will error, list the incompatible package versions, and stop creating the environment.
-
Click Create.
-
Navigator creates the r-tutorial environment and selects it as active, as shown by the highlighted green bar and green play button.
-
Click the green play button on the r-tutorial environment and select the Open with Jupyter Notebook option.
-
To create a new notebook for the R language, in the Jupyter Notebook menu, select New, then select R.
-
We will use
dplyr
to read and manipulate Fisher’s Iris multivariate data set in this tutorial. Copy and paste the following code into the first cell:library(dplyr) iris -
To run the code, in the menu bar, click Cell then select Run Cells, or use the keyboard shortcut Ctrl-Enter.
-
The iris data table is displayed.
-
Using ggplot, we can create a scatter plot comparing sepal length and width of three iris species. Click + to open a second cell, then copy and paste the following code into the second cell:
library(ggplot2) ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(size=3) -
To run the code, in the menu bar, click Cell then select Run Cells, or use the keyboard shortcut Ctrl + Enter (or Ctrl + Return in macOS).
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)