簡體   English   中英

如何將Rtools \\ bin添加到R中的系統路徑

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

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

該應用程序運行良好但我在嘗試保存輸出時出錯。 這是我獲得的錯誤:

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")指向的路徑上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM