简体   繁体   English

"如何安装“R-essentials”中不可用的 R 包?"

[英]How to install R packages that are not available in "R-essentials"?

I use an out-of-the-box Anaconda installation to work with Python.我使用开箱即用的 Anaconda 安装来使用 Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter\/Ipython notebook<\/em> .现在我已经读到,也可以在这个安装中“包含”R 世界,并在Jupyter\/Ipython notebook<\/em>中使用 IR 内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名 R 包的命令: conda install -cr r-essentials

My beginner's question:我初学者的问题:

How do I install R packages that are not included in the R-essential<\/em> package?如何安装未包含在R-essential<\/em>包中的 R 包? For example R packages that are available on CRAN.例如 CRAN 上可用的 R 包。 "pip" works only for PyPI Python packages, doesn't it? “pip”仅适用于 PyPI Python 包,不是吗?

"

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

Use Conda Forge使用康达锻造

Five years out from the original question, I'd assert that a more contemporary solution would simply be: use Conda Forge .距离最初的问题五年后,我断言更现代的解决方案只是:使用Conda Forge The Conda Forge channel not only provides broader coverage of CRAN, but also has a simple procedure and great turnaround time (typically under 24 hours) for adding a missing CRAN package to the channel. Conda Forge 频道不仅提供了更广泛的 CRAN 覆盖范围,而且还具有简单的程序和很长的周转时间(通常在 24 小时以下),可以将缺少的 CRAN 包添加到频道中。

Start from Conda Forge从 Conda Forge 开始

I'd recommend using Conda Forge for the full stack, and use a dedicated environment for each R version you require.我建议将 Conda Forge 用于完整堆栈,并为您需要的每个 R 版本使用专用环境。

conda create -n r41 -c conda-forge r-base=4.1 r-irkernel ...

where ... is whatever additional packages you require (like r-tidyverse ).其中...是您需要的任何其他软件包(例如r-tidyverse )。 The r-irkernel package is optional, but included here because OP mentions using R in Jupyter. r-irkernel包是可选的,但包含在此处是因为 OP 提到在 Jupyter 中使用 R。

If your environment with Jupyter (which should be in a separate environment) also has nb_conda_kernels installed, then this environment will automatically be discovered by Jupyter.如果您的带有 Jupyter 的环境(应该在一个单独的环境中)也安装了nb_conda_kernels ,那么 Jupyter 将自动发现这个环境。

Install from Conda Forge从 Conda Forge 安装

Generally, all R packages on CRAN have a r- prefix to the package name on Conda Forge.通常,CRAN 上的所有 R 包在 Conda Forge 上的包名称前都有一个r-前缀。 So, if your package of interest is pkgname , first try因此,如果您感兴趣的包是pkgname ,请先尝试

conda install -n r41 -c conda-forge r-pkgname

If the package is not available, then proceed to either add it or request it.如果包不可用,则继续添加或请求它。

Submit a CRAN package with Conda R Skeleton Helper使用 Conda R Skeleton Helper 提交 CRAN 包

There is a helpful script collection, called conda_r_skeleton_helper for creating new Conda Forge recipes for CRAN packages.有一个有用的脚本集合,称为conda_r_skeleton_helper ,用于为 CRAN 包创建新的 Conda Forge 配方。 There are clear directions in the README . README 中有明确的指示。

In broad strokes, one will概括地说,一个人会

  • clone the conda_r_skeleton_helper repository克隆conda_r_skeleton_helper存储库
  • edit the packages.txt file to include r-pkgname编辑packages.txt文件以包含r-pkgname
  • run the script to generate the recipe运行脚本以生成配方
  • fork and clone the conda-forge/staged-recipes fork 并克隆conda-forge/staged-recipes
  • copy the new recipe folder to the stage-recipes/recipes folder将新配方文件夹复制到stage-recipes/recipes文件夹
  • commit changes, push to the fork, then submit a Pull Request back to Conda Forge提交更改,推送到 fork,然后将 Pull Request 提交回 Conda Forge

This takes maybe ~15 mins of work.这可能需要大约 15 分钟的工作时间。 Once submitted, most packages take under 24 hours to get accepted, feedstocked, and deployed to the Conda Forge channel.提交后,大多数包在 24 小时内被接受、输入并部署到 Conda Forge 渠道。 Once the feedstock is up and running, the Conda Forge infrastructure uses a bot to auto-detect version updates, generate new pull requests, and even auto-merge Pull Requests that successfully build.一旦原料启动并运行,Conda Forge 基础设施使用机器人自动检测版本更新,生成新的拉取请求,甚至自动合并成功构建的拉取请求。 That is, maintainers have a very minimal workload, and if there are issues, a team is available to help out.也就是说,维护人员的工作量非常小,如果有问题,可以有一个团队提供帮助。

File a Package Request提交包裹请求

For users uncomfortable with creating and maintaining a Conda Forge build, packages can be requested on Conda Forge's staged-recipes repository byfiling a new Issue .对于不喜欢创建和维护 Conda Forge 构建的用户,可以通过提交新问题在 Conda Forge 的staged-recipes存储库中请求软件包。 There is a template for Package Request, that includes some information fields to be filled in. Package Request 有一个模板,其中包括一些需要填写的信息字段。

What worked for me is install.packages("package_name", type="binary")<\/code> .对我有用的是install.packages("package_name", type="binary")<\/code> 。 None of the other answers have worked.其他答案都没有奏效。

"

I use an out-of-the-box Anaconda installation to work with Python.我使用现成的Anaconda安装来使用Python。 Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook .现在,我已经知道可以在安装中“包含” R世界,并可以在Jupyter / Ipython笔记本中使用IR内核。

I found the command to install a number of famous R packages: conda install -cr r-essentials我找到了安装许多著名的R软件包的命令:conda install -cr r-essentials

My beginner's question:我的初学者的问题:

How do I install R packages that are not included in the R-essential package?如何安装R-essential软件包中未包含的R软件包? For example R packages that are available on CRAN.例如,CRAN上可用的R包。 "pip" works only for PyPI Python packages, doesn't it? “ pip”仅适用于PyPI Python软件包,不是吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM