简体   繁体   English

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

[英]How to add Rtools\bin to the system path in R

Am running a Shiny app from https://github.com/MikeJSeo/SAM and the code to access it: 我从https://github.com/MikeJSeo/SAM运行一个Shiny应用程序和访问它的代码:

install.packages(c("samr", "matrixStats", "GSA", "shiny", "openxlsx"))
source("http://bioconductor.org/biocLite.R")
biocLite("impute")
library(shiny)
runGitHub("SAM", "MikeJSeo")

The app runs great but I get a error when trying to save the output. 该应用程序运行良好但我在尝试保存输出时出错。 This is the error I obtain: 这是我获得的错误:

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")

I tried; 我试过了;

Sys.getenv("PATH")

and the output is 而输出是

[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\\"

Am assuming that my error arrises because I dont have the "Rtools\\bin" directory. 我假设我的错误是因为我没有“Rtools \\ bin”目录。 I have tried, 我努力了,

Sys.setenv("R_ZIPCMD" = "mypath/to/zip.exe")

but not luck. 但不是运气。 So how can I go about correcting this? 那么我该如何纠正这个呢?

This fixed my problem. 这解决了我的问题。

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

To answer to John Doe's question, you can make sure that Rtools is in the path always and only for R by adding this line to your .Rprofile : 要回答John Doe的问题,您可以通过将此行添加到.Rprofile来确保Rtools始终位于路径中且仅适用于R:

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

.Rprofile needs to be located at the path pointed by the command Sys.getenv("HOME") . .Rprofile需要位于命令Sys.getenv("HOME")指向的路径上。

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

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