简体   繁体   English

如何在环境变量中添加 R 和 Rtools 路径?

[英]How is to add R and Rtools paths in the environment variable?

I have installed R-3.5.1 and Rtools35.exe .我已经安装了R-3.5.1Rtools35.exe But I am unable to install packages in R .但我无法在R安装软件包。 Somewhere I got,我得到的地方,

Make sure the R and Rtools paths are added in the environment variable.确保在环境变量中添加了 R 和 Rtools 路径。

But I don't know what is environment variable and how is to add R and Rtools paths in the environment variable?但我不知道什么是环境变量以及如何在环境变量中添加 R 和 Rtools 路径?

Edit编辑

The answer provided How to add Rtools\\bin to the system path in R requires library(devtools) .提供的答案How to add Rtools\\bin to the system path in R requires library(devtools) But install.packages("devtools") isn't working.但是install.packages("devtools")不起作用。

Installing package that has heavy dependencies just to set environment variables doesn't seem to be good solution.安装具有重度依赖关系的软件包只是为了设置环境变量似乎不是一个好的解决方案。

Below solution is for R 4.0.0 and rtools40.以下解决方案适用于 R 4.0.0 和 rtools40。

This uses powershell bash, it should be available on all recent Windows versions.这使用 powershell bash,它应该可用于所有最新的 Windows 版本。

$ENV:PATH = "C:\R\bin;C:\rtools40\usr\bin;$ENV:PATH"

You can see full R 4.0.0 setup on Windows in this CI yaml .您可以在此 CI yaml 中查看 Windows 上的完整 R 4.0.0 设置。


Note that in powershell it is best to refer to applications using .exe suffix, because powershell has many aliases, so using R or curl will not do what you expect, you need R.exe or curl.exe instead.请注意,在powershell中最好引用使用.exe后缀的应用程序,因为powershell有很多别名,所以使用Rcurl不会如你R.exe ,你需要R.execurl.exe来代替。

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

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