如何将Rtools\bin添加到R中的系统路径

如何将Rtools\bin添加到R中的系统路径,r,shiny,R,Shiny,我正在运行一个闪亮的应用程序 以及访问它的代码: install.packages(c("samr", "matrixStats", "GSA", "shiny", "openxlsx")) source("http://bioconductor.org/biocLite.R") biocLite("impute") library(shiny) runGitHub("SAM", "MikeJSeo") 该应用程序运行良好,但我在尝试保存输出时出错。这是我得到的错误: Warning: Err

我正在运行一个闪亮的应用程序 以及访问它的代码:

install.packages(c("samr", "matrixStats", "GSA", "shiny", "openxlsx"))
source("http://bioconductor.org/biocLite.R")
biocLite("impute")
library(shiny)
runGitHub("SAM", "MikeJSeo")
该应用程序运行良好,但我在尝试保存输出时出错。这是我得到的错误:

Warning: Error in : zipping up workbook failed. Please make sure Rtools is installed or a zip application is available to R.
Try installr::install.rtools() on Windows. If the "Rtools\bin" directory does not appear in Sys.getenv("PATH") please add it to the system PATH 
or set this within the R session with Sys.setenv("R_ZIPCMD" = "path/to/zip.exe")
我试过了

Sys.getenv("PATH")
输出是

[1] "C:\\Program Files\\R\\R-3.4.1\\bin\\x64;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\ActivIdentity\\ActivClient\\;C:\\Program Files (x86)\\ActivIdentity\\ActivClient\\;C:\\Program Files (x86)\\Addinsoft\\XLSTAT\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\"
我假设我的错误出现是因为我没有“Rtools\bin”目录。我试过了

Sys.setenv("R_ZIPCMD" = "mypath/to/zip.exe")
但不是运气。那么我该如何着手纠正这个问题呢?

这解决了我的问题

library(devtools)
Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")

要回答John Doe的问题,您可以通过将这一行添加到
.Rprofile
,确保Rtools始终且仅适用于R:

Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))

.Rprofile
需要位于命令所指向的路径上
Sys.getenv(“HOME”)

我也有类似的问题。但每次在nem PC中打开RStudio时,我都需要将
Rtools
设置为系统路径。有没有解决这个问题的方法?