alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

【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.

  1. Start Navigator.

  2. Make sure Jupyter Notebook is installed on your Home page.

  3. To install the R language and r-essentials packages, go to the Environments page.

  4. Click Create.

    ../../../_images/jupyter-note-r-create.png
  5. Name the environment “r-tutorial”.

  6. Next to Packages, select version 3.7.13 of Python.

  7. 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.

  8. Click Create.

  9. Navigator creates the r-tutorial environment and selects it as active, as shown by the highlighted green bar and green play button.

  10. Click the green play button on the r-tutorial environment and select the Open with Jupyter Notebook option.

    ../../../_images/jupyter-note-r-open.png
  11. To create a new notebook for the R language, in the Jupyter Notebook menu, select New, then select R.

    ../../../_images/jupyter-note-r-new.png
  12. 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
  13. To run the code, in the menu bar, click Cell then select Run Cells, or use the keyboard shortcut Ctrl-Enter.

  14. The iris data table is displayed.

  15. 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)
  16. 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).

posted on   McDelfino  阅读(28)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示